Repository navigation
Conversation
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a narrowly scoped keyboard-routing bug fix that preserves existing composer behavior except when an open right-panel launcher explicitly advertises the pressed key. The change is isolated to the web event guard and targeted browser tests, with no schema, deployment, security, billing, or product-default impact. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
…r page load Type-to-focus and the launcher both listen for keydown on window in the capture phase, and type-to-focus is registered first when the panel opens after load. It typed the letter into the composer and prevented the event before the launcher saw it. Type-to-focus now skips the keys the mounted launcher advertises in data-surface-launcher-keys, which nothing read since pingdotgg#2829. Fixes pingdotgg#21541
… the launcher The chat's shortcut listener registers when the chat mounts, so a launcher that opens later registers after it. Cover that ordering with real key presses: launcher letters in either case stay out of the composer, other letters still reach it, and the launcher's letters reach it again once the launcher closes.
3f8d38a to
ed87ebf
Compare
Problem
When the right panel is opened after the page has loaded, pressing a launcher letter in the empty "Open a surface" launcher (T for Terminal, B for Browser, ...) types the letter into the composer instead of opening the surface (#21541). Type-to-focus and the launcher both add a capture
keydownlistener onwindow. Type-to-focus registers when the chat view mounts, the launcher when it mounts, so a launcher opened later runs second. Type-to-focus types the letter into the composer and prevents the event, and the launcher ignores a prevented event. The launcher still advertises its letters indata-surface-launcher-keys, but the type-to-focus check that read it was dropped in #2829.Change
shouldTypeToFocusComposerincomposerFocusRedirect.tsreturns false for a key the mounted launcher advertises indata-surface-launcher-keys(case-insensitive), so the launcher gets those letters whatever order the listeners were added in. Other letters still go to the composer, and with no launcher mounted nothing changes. Listener order, the launcher matcher and non-Latin layout handling (#21508) are untouched.Scope and approval
Triaged and accepted by the maintainer, who confirmed the listener-order cause on main: #21541 (comment)
Verification
Three cases in a new
apps/web/src/components/chat/useChatShortcuts.browser.test.tsx(#22557 removedcomposerFocusRedirect.browser.test.tson main, so the earlier cases moved here). The test mounts the realuseChatShortcutsfirst, then a launcher stand-in that registers itskeydownlistener afterwards, the order from the issue, and presses real keys:leaves the launcher's letters to the launcher, in either casefails without the change (expected [] to deeply equal [ 't', 'T' ]) and passes with it.still types other letters into the composer while the launcher is openandtypes the letter into the composer again once the launcher closespass before and after.Format, lint and
apps/webtypecheck are clean. I also merged this branch with #21508 locally: no conflicts, and the type-to-focus and RightPanelTabs tests pass together (28 tests).In the dev app (Chromium), following the issue's steps: load the page, open the right panel with its toolbar button, press T. I checked T only; the other launcher letters go through the same check.
On non-Latin keyboard layouts, when the panel opens after page load, the letter still goes to the composer even with #21508, because this check compares
event.key; also matchingevent.codehere would cover that and could be a follow-up.Before:
tlands in the composer and the launcher stays open.After: Terminal 1 opens and the composer stays empty.
Closes #21541
Claude Sonnet 5.5 (xhigh) via T3 Code.