eba997be98
# Replace hotkey scopes by focus stack (Part 6 - Remove Hotkey scopes) This PR is the last part of a refactoring aiming to deprecate the hotkey scopes api in favor of the new focus stack api which is more robust. Part 1: https://github.com/twentyhq/twenty/pull/12673 Part 2: https://github.com/twentyhq/twenty/pull/12798 Part 3: https://github.com/twentyhq/twenty/pull/12910 Part 4: https://github.com/twentyhq/twenty/pull/12933 Part 5: https://github.com/twentyhq/twenty/pull/13106 In this part, we completely remove the hotkey scopes.
46 lines
1.6 KiB
TypeScript
46 lines
1.6 KiB
TypeScript
import { Key } from 'ts-key-enum';
|
|
|
|
import { KEYBOARD_SHORTCUTS_GENERAL } from '@/keyboard-shortcut-menu/constants/KeyboardShortcutsGeneral';
|
|
import { KEYBOARD_SHORTCUTS_TABLE } from '@/keyboard-shortcut-menu/constants/KeyboardShortcutsTable';
|
|
|
|
import {
|
|
KEYBOARD_SHORTCUT_MENU_INSTANCE_ID,
|
|
useKeyboardShortcutMenu,
|
|
} from '../hooks/useKeyboardShortcutMenu';
|
|
|
|
import { useHotkeysOnFocusedElement } from '@/ui/utilities/hotkey/hooks/useHotkeysOnFocusedElement';
|
|
import { KeyboardMenuDialog } from './KeyboardShortcutMenuDialog';
|
|
import { KeyboardMenuGroup } from './KeyboardShortcutMenuGroup';
|
|
import { KeyboardMenuItem } from './KeyboardShortcutMenuItem';
|
|
|
|
export const KeyboardShortcutMenuOpenContent = () => {
|
|
const { toggleKeyboardShortcutMenu, closeKeyboardShortcutMenu } =
|
|
useKeyboardShortcutMenu();
|
|
|
|
useHotkeysOnFocusedElement({
|
|
keys: [Key.Escape],
|
|
callback: () => {
|
|
closeKeyboardShortcutMenu();
|
|
},
|
|
focusId: KEYBOARD_SHORTCUT_MENU_INSTANCE_ID,
|
|
dependencies: [closeKeyboardShortcutMenu],
|
|
});
|
|
|
|
return (
|
|
<>
|
|
<KeyboardMenuDialog onClose={toggleKeyboardShortcutMenu}>
|
|
<KeyboardMenuGroup heading="Table">
|
|
{KEYBOARD_SHORTCUTS_TABLE.map((TableShortcut, index) => (
|
|
<KeyboardMenuItem shortcut={TableShortcut} key={index} />
|
|
))}
|
|
</KeyboardMenuGroup>
|
|
<KeyboardMenuGroup heading="General">
|
|
{KEYBOARD_SHORTCUTS_GENERAL.map((GeneralShortcut) => (
|
|
<KeyboardMenuItem shortcut={GeneralShortcut} />
|
|
))}
|
|
</KeyboardMenuGroup>
|
|
</KeyboardMenuDialog>
|
|
</>
|
|
);
|
|
};
|