feat: add validation for search modal

This commit is contained in:
Sonny
2024-05-25 17:18:33 +02:00
committed by Sonny
parent 56c05f1bf6
commit 09700a1916
12 changed files with 306 additions and 64 deletions

View File

@@ -4,13 +4,15 @@ import useGlobalHotkeys from '~/hooks/use_global_hotkeys';
type ShortcutOptions = {
enabled?: boolean;
disableGlobalCheck?: boolean;
};
export default function useShortcut(
key: keyof typeof KEYS,
cb: () => void,
{ enabled }: ShortcutOptions = {
{ enabled, disableGlobalCheck }: ShortcutOptions = {
enabled: true,
disableGlobalCheck: false,
}
) {
const { globalHotkeysEnabled } = useGlobalHotkeys();
@@ -21,7 +23,7 @@ export default function useShortcut(
cb();
},
{
enabled: key === 'ESCAPE_KEY' ? true : enabled && globalHotkeysEnabled,
enabled: disableGlobalCheck ? enabled : enabled && globalHotkeysEnabled,
enableOnFormTags: ['INPUT'],
}
);