From dddf67ed0163de01000860af4214ea0cc490e29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bosi?= <71827178+bosiraphael@users.noreply.github.com> Date: Thu, 27 Feb 2025 18:14:45 +0100 Subject: [PATCH] Prevent command menu backspace shortcut on V1 (#10555) Before: https://github.com/user-attachments/assets/87be65fa-4b24-4e15-b0a4-ca1aa06f5ca6 After: https://github.com/user-attachments/assets/ef9076a0-214f-4680-a455-157a206e8197 --- .../modules/command-menu/hooks/useCommandMenuHotKeys.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 012b804a7..3b3ade6f1 100644 --- a/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuHotKeys.ts +++ b/packages/twenty-front/src/modules/command-menu/hooks/useCommandMenuHotKeys.ts @@ -8,9 +8,11 @@ import { useKeyboardShortcutMenu } from '@/keyboard-shortcut-menu/hooks/useKeybo import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys'; import { AppHotkeyScope } from '@/ui/utilities/hotkey/types/AppHotkeyScope'; import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2'; +import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; import { isNonEmptyString } from '@sniptt/guards'; import { useRecoilValue } from 'recoil'; import { Key } from 'ts-key-enum'; +import { FeatureFlagKey } from '~/generated-metadata/graphql'; export const useCommandMenuHotKeys = () => { const { @@ -31,6 +33,10 @@ export const useCommandMenuHotKeys = () => { COMMAND_MENU_COMPONENT_INSTANCE_ID, ); + const isCommandMenuV2Enabled = useIsFeatureEnabled( + FeatureFlagKey.IsCommandMenuV2Enabled, + ); + useScopedHotkeys( 'ctrl+k,meta+k', () => { @@ -65,7 +71,7 @@ export const useCommandMenuHotKeys = () => { useScopedHotkeys( [Key.Backspace, Key.Delete], () => { - if (isNonEmptyString(commandMenuSearch)) { + if (isNonEmptyString(commandMenuSearch) || !isCommandMenuV2Enabled) { return; }