fix(ui): stop shortcuts from eating keystrokes in text fields#38
Merged
Conversation
Pierre's file tree renders in an open shadow root, so keydowns from its
in-tree search box reach window listeners with e.target retargeted to the
shadow host — every e.target.closest('input…') guard missed it and view
shortcuts (j/k, Shift+J/K, s, d, space…) swallowed typing; capitals were
the visible casualty since they arrive as Shift+letter.
Add eventInside() to lib/keys.ts (walks composedPath so open shadow roots
are seen through, with a closest() fallback) plus a shared
EDITABLE_SELECTOR, and use them in every window/document-level key
handler (App global dispatch, Review, LocalChanges, WorkspaceReview,
Commits '/' focus, MergeResolver stepping — which had no text-field guard
at all).
Also tighten the text-field rule to "only Mod+ combos may act":
isPlainKey() now flags any binding without Mod, so Shift-only and
Alt-only bindings never fire while typing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
User report: typing in the file-search box still triggered keyboard shortcuts, so capital letters (which arrive as
Shift+letter) could not be typed.Root cause: Pierre's file tree renders in an open shadow root, and keydown events from its in-tree search box are retargeted — window-level listeners see the shadow host as
e.target, so everye.target.closest('input…')guard in the app failed and view shortcuts (j/k,Shift+J/K,s,d, space…) swallowed the keystrokes.eventInside()+EDITABLE_SELECTORtolib/keys.ts— walkscomposedPath()(which crosses open shadow roots) with aclosest()fallback, duck-typed so the module stays unit-testable in node.App.tsx,Review,LocalChanges,WorkspaceReview, the/focus-search handler inCommits, andMergeResolver's[/]/arrow stepping (which had no text-field guard at all despite its comment).Mod+…combos may act while typing:isPlainKey()now flags any binding withoutMod, so Shift-only and Alt-only bindings (typing: capitals, composed characters) never fire in text fields.Test plan
pnpm exec tsc --noEmit— cleanpnpm exec vitest run— 200/200 passing, including new tests for theisPlainKeysemantics andeventInsideshadow-DOM retargeting/fallback pathspnpm run build— succeeds🤖 Generated with Claude Code