diff --git a/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-custom-reports-Switches-to-Donut-Graph-and-checks-the-visuals-1-chromium-linux.png b/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-custom-reports-Switches-to-Donut-Graph-and-checks-the-visuals-1-chromium-linux.png index 2f01d4b21a4..8b6fb7dfc07 100644 Binary files a/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-custom-reports-Switches-to-Donut-Graph-and-checks-the-visuals-1-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-custom-reports-Switches-to-Donut-Graph-and-checks-the-visuals-1-chromium-linux.png differ diff --git a/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-custom-reports-Switches-to-Donut-Graph-and-checks-the-visuals-2-chromium-linux.png b/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-custom-reports-Switches-to-Donut-Graph-and-checks-the-visuals-2-chromium-linux.png index 2619303ee1f..e821884d439 100644 Binary files a/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-custom-reports-Switches-to-Donut-Graph-and-checks-the-visuals-2-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-custom-reports-Switches-to-Donut-Graph-and-checks-the-visuals-2-chromium-linux.png differ diff --git a/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-custom-reports-Switches-to-Donut-Graph-and-checks-the-visuals-3-chromium-linux.png b/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-custom-reports-Switches-to-Donut-Graph-and-checks-the-visuals-3-chromium-linux.png index e91f7df9a86..986929ddd5d 100644 Binary files a/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-custom-reports-Switches-to-Donut-Graph-and-checks-the-visuals-3-chromium-linux.png and b/packages/desktop-client/e2e/reports.test.js-snapshots/Reports-custom-reports-Switches-to-Donut-Graph-and-checks-the-visuals-3-chromium-linux.png differ diff --git a/packages/desktop-client/src/components/accounts/Header.tsx b/packages/desktop-client/src/components/accounts/Header.tsx index c45ae73eb1c..4a66ebc45de 100644 --- a/packages/desktop-client/src/components/accounts/Header.tsx +++ b/packages/desktop-client/src/components/accounts/Header.tsx @@ -369,7 +369,7 @@ export function AccountHeader({ onMakeAsNonSplitTransactions={onMakeAsNonSplitTransactions} /> )} - + {account && ( <> {account ? ( - + ) : ( - + { - if (!contextMenusEnabled) return; - e.preventDefault(); - setMenuOpen(true); - }} + onContextMenu={handleContextMenu} >
setMenuOpen(true)} + onPress={() => { + resetPosition(); + setMenuOpen(true); + }} > setMenuOpen(false)} - style={{ width: 200 }} + style={{ width: 200, margin: 1 }} isNonModal + {...position} > { diff --git a/packages/desktop-client/src/components/budget/SidebarGroup.tsx b/packages/desktop-client/src/components/budget/SidebarGroup.tsx index 20a81eba986..87e6eaad4d2 100644 --- a/packages/desktop-client/src/components/budget/SidebarGroup.tsx +++ b/packages/desktop-client/src/components/budget/SidebarGroup.tsx @@ -1,8 +1,9 @@ // @ts-strict-ignore -import React, { type CSSProperties, useRef, useState } from 'react'; +import React, { type CSSProperties, useRef } from 'react'; import { type ConnectDragSource } from 'react-dnd'; import { useTranslation } from 'react-i18next'; +import { useContextMenu } from '../../hooks/useContextMenu'; import { useFeatureFlag } from '../../hooks/useFeatureFlag'; import { SvgExpandArrow } from '../../icons/v0'; import { SvgCheveronDown } from '../../icons/v1'; @@ -58,9 +59,9 @@ export function SidebarGroup({ const isGoalTemplatesEnabled = useFeatureFlag('goalTemplatesEnabled'); const temporary = group.id === 'new'; - const [menuOpen, setMenuOpen] = useState(false); + const { setMenuOpen, menuOpen, handleContextMenu, resetPosition, position } = + useContextMenu(); const triggerRef = useRef(null); - const contextMenusEnabled = useFeatureFlag('contextMenus'); const displayed = ( { onToggleCollapse(group.id); }} - onContextMenu={e => { - if (!contextMenusEnabled) return; - e.preventDefault(); - setMenuOpen(true); - }} + onContextMenu={handleContextMenu} > {!dragPreview && ( setMenuOpen(true)} + onPress={() => { + resetPosition(); + setMenuOpen(true); + }} style={{ padding: 3 }} > @@ -122,8 +122,9 @@ export function SidebarGroup({ placement="bottom start" isOpen={menuOpen} onOpenChange={() => setMenuOpen(false)} - style={{ width: 200 }} + style={{ width: 200, margin: 1 }} isNonModal + {...position} > { diff --git a/packages/desktop-client/src/components/budget/envelope/EnvelopeBudgetComponents.tsx b/packages/desktop-client/src/components/budget/envelope/EnvelopeBudgetComponents.tsx index 78a42e0fd8d..0bb0491a2d8 100644 --- a/packages/desktop-client/src/components/budget/envelope/EnvelopeBudgetComponents.tsx +++ b/packages/desktop-client/src/components/budget/envelope/EnvelopeBudgetComponents.tsx @@ -3,7 +3,6 @@ import React, { type CSSProperties, memo, useRef, - useState, } from 'react'; import { useTranslation, Trans } from 'react-i18next'; @@ -14,7 +13,7 @@ import { evalArithmetic } from 'loot-core/src/shared/arithmetic'; import * as monthUtils from 'loot-core/src/shared/months'; import { integerToCurrency, amountToInteger } from 'loot-core/src/shared/util'; -import { useFeatureFlag } from '../../../hooks/useFeatureFlag'; +import { useContextMenu } from '../../../hooks/useContextMenu'; import { useUndo } from '../../../hooks/useUndo'; import { SvgCheveronDown } from '../../../icons/v1'; import { styles, theme } from '../../../style'; @@ -207,8 +206,20 @@ export const ExpenseCategoryMonth = memo(function ExpenseCategoryMonth({ const budgetMenuTriggerRef = useRef(null); const balanceMenuTriggerRef = useRef(null); - const [budgetMenuOpen, setBudgetMenuOpen] = useState(false); - const [balanceMenuOpen, setBalanceMenuOpen] = useState(false); + const { + setMenuOpen: setBudgetMenuOpen, + menuOpen: budgetMenuOpen, + handleContextMenu: handleBudgetContextMenu, + resetPosition: resetBudgetPosition, + position: budgetPosition, + } = useContextMenu(); + const { + setMenuOpen: setBalanceMenuOpen, + menuOpen: balanceMenuOpen, + handleContextMenu: handleBalanceContextMenu, + resetPosition: resetBalancePosition, + position: balancePosition, + } = useContextMenu(); const onMenuAction = (...args: Parameters) => { onBudgetAction(...args); @@ -216,7 +227,6 @@ export const ExpenseCategoryMonth = memo(function ExpenseCategoryMonth({ }; const { showUndoNotification } = useUndo(); - const contextMenusEnabled = useFeatureFlag('contextMenus'); return ( { - if (!contextMenusEnabled) return; if (editing) return; - e.preventDefault(); - setBudgetMenuOpen(true); + handleBudgetContextMenu(e); }} > {!editing && ( @@ -261,9 +270,11 @@ export const ExpenseCategoryMonth = memo(function ExpenseCategoryMonth({ }} >