From 9838bec0041ec456529e97e4ad94acc9a4109da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bosi?= <71827178+bosiraphael@users.noreply.github.com> Date: Thu, 6 Feb 2025 10:07:20 +0100 Subject: [PATCH] 259 add navigation hotkeys for command menu level 2 (#10043) Closes https://github.com/twentyhq/core-team-issues/issues/259 https://github.com/user-attachments/assets/abdcb44d-fc13-4597-befc-da99c94c1ef0 --- .../hooks/useCommandMenuHotKeys.ts | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuHotKeys.ts b/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuHotKeys.ts index fe5dc1365..a58245998 100644 --- a/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuHotKeys.ts +++ b/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuHotKeys.ts @@ -13,9 +13,9 @@ import { Key } from 'ts-key-enum'; export const useCommandMenuHotKeys = () => { const { - closeCommandMenu, openRecordsSearchPage, toggleCommandMenu, + goBackFromCommandMenu, setGlobalCommandMenuContext, } = useCommandMenu(); @@ -37,7 +37,7 @@ export const useCommandMenuHotKeys = () => { toggleCommandMenu(); }, AppHotkeyScope.CommandMenu, - [toggleCommandMenu], + [closeKeyboardShortcutMenu, toggleCommandMenu], ); useScopedHotkeys( @@ -55,18 +55,21 @@ export const useCommandMenuHotKeys = () => { useScopedHotkeys( [Key.Escape], () => { - closeCommandMenu(); + goBackFromCommandMenu(); }, AppHotkeyScope.CommandMenuOpen, - [closeCommandMenu], + [goBackFromCommandMenu], ); useScopedHotkeys( [Key.Backspace, Key.Delete], () => { + if (isNonEmptyString(commandMenuSearch)) { + return; + } + if ( commandMenuPage === CommandMenuPages.Root && - !isNonEmptyString(commandMenuSearch) && !( contextStoreTargetedRecordsRuleComponent.mode === 'selection' && contextStoreTargetedRecordsRuleComponent.selectedRecordIds.length === @@ -75,9 +78,18 @@ export const useCommandMenuHotKeys = () => { ) { setGlobalCommandMenuContext(); } + if (commandMenuPage !== CommandMenuPages.Root) { + goBackFromCommandMenu(); + } }, AppHotkeyScope.CommandMenuOpen, - [closeCommandMenu], + [ + commandMenuPage, + commandMenuSearch, + contextStoreTargetedRecordsRuleComponent, + goBackFromCommandMenu, + setGlobalCommandMenuContext, + ], { preventDefault: false, },