diff --git a/packages/twenty-front/src/modules/app/components/AppRouterProviders.tsx b/packages/twenty-front/src/modules/app/components/AppRouterProviders.tsx index df7bb083f9dc..7f64849a27e0 100644 --- a/packages/twenty-front/src/modules/app/components/AppRouterProviders.tsx +++ b/packages/twenty-front/src/modules/app/components/AppRouterProviders.tsx @@ -1,5 +1,4 @@ import { ApolloProvider } from '@/apollo/components/ApolloProvider'; -import { CommandMenuEffect } from '@/app/effect-components/CommandMenuEffect'; import { GotoHotkeysEffectsProvider } from '@/app/effect-components/GotoHotkeysEffectsProvider'; import { PageChangeEffect } from '@/app/effect-components/PageChangeEffect'; import { AuthProvider } from '@/auth/components/AuthProvider'; @@ -44,7 +43,6 @@ export const AppRouterProviders = () => { - diff --git a/packages/twenty-front/src/modules/app/effect-components/CommandMenuEffect.tsx b/packages/twenty-front/src/modules/app/effect-components/CommandMenuEffect.tsx deleted file mode 100644 index b210ae724276..000000000000 --- a/packages/twenty-front/src/modules/app/effect-components/CommandMenuEffect.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { useEffect } from 'react'; -import { useSetRecoilState } from 'recoil'; - -import { COMMAND_MENU_COMMANDS } from '@/command-menu/constants/CommandMenuCommands'; -import { commandMenuCommandsState } from '@/command-menu/states/commandMenuCommandsState'; - -export const CommandMenuEffect = () => { - const setCommands = useSetRecoilState(commandMenuCommandsState); - - const commands = Object.values(COMMAND_MENU_COMMANDS); - useEffect(() => { - setCommands(commands); - }, [commands, setCommands]); - - return <>; -}; diff --git a/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenu.ts b/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenu.ts index 06fc6469bce3..c1bf10c69c4e 100644 --- a/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenu.ts +++ b/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenu.ts @@ -43,6 +43,8 @@ export const useCommandMenu = () => { }), ); + const commands = Object.values(COMMAND_MENU_COMMANDS); + const actionCommands = actionMenuEntries .getValue() ?.map((actionMenuEntry) => ({ @@ -53,7 +55,7 @@ export const useCommandMenu = () => { type: CommandType.Action, })); - setCommands(actionCommands); + setCommands([...commands, ...actionCommands]); } setIsCommandMenuOpened(true); @@ -76,11 +78,17 @@ export const useCommandMenu = () => { if (isCommandMenuOpened) { setIsCommandMenuOpened(false); + setCommands([]); resetSelectedItem(); goBackToPreviousHotkeyScope(); } }, - [goBackToPreviousHotkeyScope, resetSelectedItem, setIsCommandMenuOpened], + [ + goBackToPreviousHotkeyScope, + resetSelectedItem, + setCommands, + setIsCommandMenuOpened, + ], ); const toggleCommandMenu = useRecoilCallback(