Skip to content

fix(ui): CommandPalette Ctrl/Cmd+K shortcut fires when focus is on text-entry controls #407

@github-actions

Description

@github-actions

Summary

The document-level keydown handler in CommandPalette.tsx fires on all events regardless of which element is focused. If a user is typing in an <input>, <textarea>, <select>, or contentEditable element and presses Ctrl/Cmd+K, the palette opens and steals focus, interrupting their workflow.

Affected file

src/UILayer/web/src/components/shared/CommandPalette.tsx — lines 41-50

Required fix

function handleKeyDown(e: KeyboardEvent) {
  const target = e.target as HTMLElement | null
  if (
    target &&
    (target.tagName === 'INPUT' ||
      target.tagName === 'TEXTAREA' ||
      target.tagName === 'SELECT' ||
      target.isContentEditable)
  ) {
    return
  }
  if ((e.metaKey || e.ctrlKey) && e.key === 'k') {
    e.preventDefault()
    setOpen((prev) => !prev)
  }
}

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions