addressed comment

This commit is contained in:
Harsh Mahajan
2025-11-12 07:40:41 +00:00
parent dc69034cd8
commit ac02658df8
2 changed files with 4 additions and 8 deletions
+2 -2
View File
@@ -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();
}
+2 -6
View File
@@ -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;