diff --git a/src/lib/commandCenter/commandCenter.svelte b/src/lib/commandCenter/commandCenter.svelte index 6611d3c91..91bf5dfe9 100644 --- a/src/lib/commandCenter/commandCenter.svelte +++ b/src/lib/commandCenter/commandCenter.svelte @@ -33,7 +33,7 @@ import { commandCenterKeyDownHandler, disableCommands, - isKeyboardEventFromInput, + isTargetInputLike, registerCommands } from './commands'; import { RootPanel } from './panels'; @@ -102,7 +102,7 @@ const handleKeydown = (e: KeyboardEvent) => { if (!$subPanels.length) { - if (isKeyboardEventFromInput(e)) return; + if (isTargetInputLike(e.target)) return; keys = [...keys, e.key].slice(-10); resetKeys(); } diff --git a/src/lib/commandCenter/commands.ts b/src/lib/commandCenter/commands.ts index 6ebe35c10..e4f383718 100644 --- a/src/lib/commandCenter/commands.ts +++ b/src/lib/commandCenter/commands.ts @@ -100,17 +100,13 @@ const commandsEnabled = derived(disabledMap, ($disabledMap) => { return Array.from($disabledMap.values()).every((disabled) => !disabled); }); -function isTargetInputLike(element: EventTarget | null) { +export function isTargetInputLike(element: EventTarget | null) { if (!(element instanceof HTMLElement)) return false; return !!element.closest( 'input,textarea,select,[contenteditable],[role="combobox"],[role="textbox"],[role="searchbox"],[data-command-center-ignore]' ); } -export function isKeyboardEventFromInput(event: KeyboardEvent) { - return isTargetInputLike(event.target); -} - function getCommandRank(command: KeyedCommand) { const { keys, ctrl: meta, shift, alt } = command; const modifiers = [meta, shift, alt].filter(Boolean).length; @@ -214,7 +210,7 @@ export const commandCenterKeyDownHandler = derived( if ( command.disabled || !enabled || - isKeyboardEventFromInput(event) || + isTargetInputLike(event.target) || $wizard.show ) { continue;