fix(ext/popup): don't eat '/' and other keystrokes while typing in inputs
Bug: item-list's global "/" shortcut (focus search) and "+" shortcut (new item) fired even when focus was inside any input/textarea other than the list's own search field. This ate forward-slashes typed into the setup wizard's host-url field and the add/edit form's notes area, and would have done the same for any printable shortcut in a future text field. Root cause: the handler was attached to `document`, stays attached when the user opens an item (and its click-handler navigated without removing the listener), and only excluded the search field by id. Fix: - Add isEditableTarget() helper — returns true for INPUT/TEXTAREA/SELECT and contenteditable elements. Global shortcut handlers bail early when this fires, passing the keystroke through to the field. - Apply the same guard in item-detail.ts (previously only guarded against INPUT, missing TEXTAREA + contenteditable). - Remove handleListKeydown on row-click so it doesn't linger on detail/edit views even before the route-transition keydown listeners install. - Escape in the list view still works from inside an editable field — only the printable-character interceptions are gated. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -207,7 +207,13 @@ function renderLogin(app: HTMLElement, item: Item): void {
|
||||
|
||||
// --- Keyboard shortcuts ---
|
||||
const handler = async (e: KeyboardEvent) => {
|
||||
if ((e.target as HTMLElement).tagName === 'INPUT') return;
|
||||
// Bail if the user is typing into any editable field — don't steal
|
||||
// printable keystrokes meant for an input/textarea/contenteditable element.
|
||||
const t = e.target;
|
||||
if (t instanceof HTMLElement) {
|
||||
const tag = t.tagName;
|
||||
if (tag === 'INPUT' || tag === 'TEXTAREA' || tag === 'SELECT' || t.isContentEditable) return;
|
||||
}
|
||||
|
||||
switch (e.key) {
|
||||
case 'Escape':
|
||||
|
||||
Reference in New Issue
Block a user