Repository navigation
fix(DropdownMenu): return focus to the trigger after a pointer dismissal, without a ring - #6825
Conversation
…sal, without a ring DropdownMenu blurred its trigger after a pointer pick or an outside press, so focus fell to the page and the next arrow key went nowhere. Focus now returns to the trigger with the ring suppressed after pointer input, through the shared focus-return visibility helper the bottom-sheet presentation already used, and stays visible after a keyboard pick. A press outside that landed on a focusable control keeps focus there.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression15 of 420 shot(s) changed. A change here is a question, not a failure: check whether the after is the
Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
Thanks for the careful fix — returning focus to the trigger after a pointer dismissal, with the ring suppressed for pointer use and kept for keyboard use, reads clearly and the added tests cover the pick, outside-press, and landed-on-a-control cases well.
Approval needs one maintainer decision first. Today the shared interaction record settles only whether a returned focus shows its ring; the DropdownMenu record itself is still a draft and does not yet state where focus goes when the pointer menu closes, and this change proposes that rule as a still-pending decision. A maintainer needs to provide or identify the governing spec claim that settles this focus destination — returning focus to the trigger on pointer-menu close, with focus left on a control an outside press landed on — or update that claim so the proposed rule becomes current. Nothing needs to be removed or split for this reason, and no code defect was found; once that destination is settled, the implementation evidence here can carry the approval.
[Automated review]
Resolves against the landed shared press model (meta#6681): - DropdownMenu.tsx: keep both declarations; the hide path cancels the press gesture first, then runs focus return. - DropdownMenu.test.tsx: keep the press-model suite and the focus-return suite as separate blocks. - DropdownMenu.spec.md: keep the module's FR5, renumber this PR's focus-return invariant FR9 -> FR6 (the stack's FR6-FR8 are not on main), and number its decision DEC-1 (main carries no component-local decision). 108 DropdownMenu tests pass; check:knowledge aligned.
There was a problem hiding this comment.
Thanks for the careful fix — returning focus to the trigger after a pointer dismissal, with the ring suppressed for pointer use and kept for keyboard use, reads clearly and the added tests cover the pick, outside-press, and landed-on-a-control cases well.
Approval needs one maintainer decision first. Today the shared interaction record settles only whether a returned focus shows its ring; the DropdownMenu record itself is still a draft and does not yet state where focus goes when the pointer menu closes, and this change proposes that rule as a still-pending decision. A maintainer needs to provide or identify the governing spec claim that settles this focus destination — returning focus to the trigger on pointer-menu close, with focus left on a control an outside press landed on — or update that claim so the proposed rule becomes current. Nothing needs to be removed or split for this reason, and no code defect was found; once that destination is settled, the implementation evidence here can carry the approval.
[Automated review]
…6901) #6825 made a pointer dismissal return focus to the trigger with the ring suppressed. The suppression belongs to that pointer, not to the trigger, so a keyboard user who tabs away and back must get the ring again — the trigger's own onFocus clears the suppression once the modality is keyboard. No test covered that second half: deleting the onFocusReturnTargetFocus call left all 108 DropdownMenu tests green. This adds the assertion. Verified as a real guard by removing both call sites, which fails exactly this case. Test-only; no runtime change and no changeset.
Both sides appended to DropdownMenu's invariant table, verification map and test file. Main's FR6 (focus return after a pointer dismissal, from meta#6825) and its DEC-1 are kept as they landed; this branch's menuMaxHeight invariant is renumbered FR10 -> FR7 and its decision DEC-3 -> DEC-2, since main's DEC-1 now holds that number. Both test suites are preserved in full.
Both sides appended to DropdownMenu's invariant table, verification map, decision log and test file. Main's focus-return work (meta#6825) keeps FR6 and DEC-1; this branch's press model becomes FR7 and the trigger render prop FR8, with its decision renumbered to DEC-2. The trigger Button now carries both the press handlers from the stacked change and main's focus-return props. Both test suites are preserved.
Main's focus-return work (meta#6825) keeps FR6 and DEC-1; this branch's press model invariant becomes FR7. The trigger Button carries both sides: the press handlers and composed click capture from here, and main's suppressed focus ring and onFocus return.
Main's focus-return work (meta#6825) keeps FR6 and DEC-1; the triangle invariant becomes FR7 and its decision DEC-2. Both test suites are preserved, and the hover hook's imports are combined.
User impact
Anyone who picks a
DropdownMenurow with a mouse or finger, or presses outside the menu on nothing focusable. The menu closes and focus lands on the page body:handleLayerHideblurs the trigger after every pointer dismissal. A keyboard user who then reaches for the arrows has lost their place; a screen-reader user hears nothing after the pick. Restoring focus to the trigger keeps the person where they were.Problem and solution fit
Why it occurs: the blur was added so Safari would not paint a focus ring on the trigger after a touch pick. Why it harms: dropping focus to the body makes the next keyboard step start from nowhere and silences assistive technology. Why it matters: the bottom-sheet presentation of the same component already solved this the right way — return focus and suppress the ring after pointer input — so the two presentations disagree. The fix makes the pointer menu do what the sheet does.
Expected behavior and authority
architecture:interaction-modalityINV1: a returned focus after pointer input does not show the keyboard indicator. TheDropdownMenurecord is a draft and does not yet state focus return; this PR adds FR9 andcomponent:DropdownMenu/DEC-3(pointer dismissal returns focus to the trigger, ring suppressed). The one owner decision needed is that DEC-3. A draft is not approval.Smallest restoration
handleLayerHidereturns focus to the trigger through the existinguseFocusReturnVisibilityhelper instead of blurring it, unless a press outside already moved focus to a focusable control, which keeps it. No API, type, default, visual or theming change. One existing test is rewritten to the corrected contract: "does not leave focus on the trigger after pointer dismissal" → "returns focus to the trigger after pointer dismissal without a focus ring".Evidence
document.activeElementis the body.Scope
Testing
pnpm check:repopasses;eslinton the touched files: 0 errors.The 2 failures are
ContextMenu.test.tsxbottom-sheet cases that fail identically on a baremaincheckout in this environment; every DropdownMenu case passes.