Skip to content

Commit ac02658

Browse files
committed
addressed comment
1 parent dc69034 commit ac02658

2 files changed

Lines changed: 4 additions & 8 deletions

File tree

src/lib/commandCenter/commandCenter.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import {
3434
commandCenterKeyDownHandler,
3535
disableCommands,
36-
isKeyboardEventFromInput,
36+
isTargetInputLike,
3737
registerCommands
3838
} from './commands';
3939
import { RootPanel } from './panels';
@@ -102,7 +102,7 @@
102102
103103
const handleKeydown = (e: KeyboardEvent) => {
104104
if (!$subPanels.length) {
105-
if (isKeyboardEventFromInput(e)) return;
105+
if (isTargetInputLike(e.target)) return;
106106
keys = [...keys, e.key].slice(-10);
107107
resetKeys();
108108
}

src/lib/commandCenter/commands.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,13 @@ const commandsEnabled = derived(disabledMap, ($disabledMap) => {
100100
return Array.from($disabledMap.values()).every((disabled) => !disabled);
101101
});
102102

103-
function isTargetInputLike(element: EventTarget | null) {
103+
export function isTargetInputLike(element: EventTarget | null) {
104104
if (!(element instanceof HTMLElement)) return false;
105105
return !!element.closest(
106106
'input,textarea,select,[contenteditable],[role="combobox"],[role="textbox"],[role="searchbox"],[data-command-center-ignore]'
107107
);
108108
}
109109

110-
export function isKeyboardEventFromInput(event: KeyboardEvent) {
111-
return isTargetInputLike(event.target);
112-
}
113-
114110
function getCommandRank(command: KeyedCommand) {
115111
const { keys, ctrl: meta, shift, alt } = command;
116112
const modifiers = [meta, shift, alt].filter(Boolean).length;
@@ -214,7 +210,7 @@ export const commandCenterKeyDownHandler = derived(
214210
if (
215211
command.disabled ||
216212
!enabled ||
217-
isKeyboardEventFromInput(event) ||
213+
isTargetInputLike(event.target) ||
218214
$wizard.show
219215
) {
220216
continue;

0 commit comments

Comments
 (0)