mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 15:05:35 +00:00
feat: add validation for search modal
This commit is contained in:
@@ -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'],
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user