Repository navigation
improve(ui): keep the focus ring to keyboard input - #190535
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. What this changesThis PR makes programmatic menu and question-panel focus rings follow keyboard or pointer input. Example: First mouse click on an Automations row menu in Safari.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain Keep this PR open: the visual improvement is supported by browser screenshots, but the listener ratchet and an affected theme test need focused repairs. Priority: P3 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe Control UI’s shared menu and overlay owners move DOM focus; the new helper supplies input modality to the browser’s existing focus-visible styling. flowchart LR
A[Keyboard and pointer events] --> B[Input modality helper]
C[Menu navigation] --> B
D[Overlay focus return] --> B
E[Question panel] --> B
B --> F[Browser focus and ring]
Technical reviewBest possible solution: Retain the shared modality helper and existing focus owners, use the supported listener primitive, and make the theme test establish keyboard focus explicitly. Do we have a high-confidence way to reproduce the issue? Current-main script focus and cancelled trigger pointerdown support the reported first-open behavior, corroborated by the supplied Safari before screenshot; no target code was executed. Is this the best way to solve the issue? The shared helper is a small, coherent fix that preserves real focus and existing styling; the recorded same-row keyboard limitation does not require broader machinery. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9c62fce8a37d. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +37, Tests +74. Total +111 across 9 files. Added test files: 1. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 1, 2026, 12:10 PM ET / 17:10 UTC. |
|
Merged via squash.
|
* improve(ui): keep the focus ring to keyboard input * improve(ui): show the ring on any key in a pointer-opened menu * fix(ui): repaint the ring after a key's own handlers run
What Problem This Solves
Opening a menu with a mouse or finger could paint the thick accent focus ring on its first item, and the ring could move to the trigger afterwards. It looked random: the same menu showed it on the first open after a page load and not on the second.
Menus focus their first item from script, and their triggers cancel
pointerdown, so the click itself moves no focus. Both Chromium and Safari then decide:focus-visiblefor script focus from how focus last moved. A page load with no earlier focus gives a ring; an earlier click that focused something, such asmain, gives none. The result depended on what had been clicked before, not on the menu. Measured on current main, real Safari and Chromium agree: first open after load shows the ring on Automations and Usage, and a second open after clicking elsewhere does not./askhas the same cause: its question panel takes focus from script on load, so the whole panel showed the ring until the first tap.User Impact
Mouse and touch no longer show the ring when a menu opens, when focus returns to its trigger, or when
/askloads or collapses its question. Keyboard users keep it: opening with Enter, Space or arrows shows the ring on the first item, and Escape returns to a ringed trigger. Any key press in a mouse-opened menu shows the ring on the current row, including Home on the first row and a one-item menu; modifier keys alone don't. After a full page load/askhas no input to go on, so a keyboard user sees its ring on the first key press; arriving by keyboard from inside the app shows it at once.Why This Change Was Made
Focus still moves to the same elements, so keyboard behavior doesn't change. A key press that leaves focus where a pointer put it refocuses that element once to paint the ring, after the page's own key handlers have run, and a screen reader can announce it again at that moment. A small helper records whether the last input was a key or a pointer and passes
focusVisibletofocus(), which Chromium and Safari both honored here. Because the browser's own state changes, every existing:focus-visiblerule follows it and no CSS or per-page override is needed. Text fields keep their native indication.It is applied in the shared
Menuand overlay return focus, so every page gets it. Pages don't needpointerFocus="trigger"to avoid the ring. Outlines aren't removed anywhere.Left alone:
dialog.close()restores focus. Both are native dialog focus, not script, so this helper doesn't reach them. Changing that means changing how every modal opens, so it needs its own decision.Evidence
Real clicks and keys against the mock's data, with no DOM changes. Safari 27.0.1 images use real OS clicks; no keys were sent to Safari.
Before, Safari, Absolutely dark, first click:

After, Safari, Absolutely dark, first click:

After, Safari, CRT, first click:

After, Chromium, Absolutely light, first click:

After, Chromium, Absolutely dark, 390px, tap on Usage Export:

Keyboard, Chromium, Absolutely light, Tab then Enter keeps the ring:

/askbefore, Safari, Absolutely light, on load:/askafter, Safari, Absolutely light, on load:Local checks: oxfmt, oxlint,
tsgo:ui, menu, overlay, modal, question and sidebar menu tests, andui:check-performance:base.