Repository navigation
fix(DropdownMenu): a field or button a menu hosts beside its rows keeps its own keys - #7309
Conversation
…ps its own keys The menus' keydown handlers took every key from inside the menu: typeahead cancelled printable keys, Enter and Space were cancelled as row activation, and arrows, Home and End roved the rows, so a field hosted in a DropdownMenu, ContextMenu or sub-menu could not be typed in and a hosted button could not be pressed from the keyboard. Enter and Space now activate rows only, typeahead skips a hosted text field, the menus turn on useListFocus's caret guard, and a hosted field keeps a sub-menu's Left key. Rows, Tab and Escape are unchanged.
|
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 Regression26 of 448 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 6 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
Thank you — this cleanly fixes a real dead end: a filter field or action button composed inside one of these menus can now actually be used from the keyboard.
What I verified: typed text and Space stay in a hosted field in DropdownMenu, ContextMenu, and a sub-menu flyout; caret keys stay in the field until the text edge, where focus hands back to the rows; Enter and Space press a hosted button; and rows, typeahead, Tab, and Escape behave exactly as before, including controls nested inside a row. The new cases and the surrounding menu, Selector, and hook suites pass, and the HostedField story behaves as described in real Chromium.
Two small things worth a maintainer's eye, neither blocking this fix: axe flags the composed menu for containing a textbox and a button as aria-required-children, so it may be worth deciding what ownership anatomy the docs should bless for hosted controls; and a hosted native select gets its Enter/Space back but its arrow and printable keys still rove the rows, which could be a follow-up if that composition matters.
No public API or default changes, and the changeset looks right. Happy to see this land.
[Automated review]
cixzhang
left a comment
There was a problem hiding this comment.
CodeBunny approved at this head; CI green. Approved.
…#7338) * revert: menus no longer special-case controls placed among their rows Reverts #7309 before it ships. A menu holds only menu items: role="menu" admits menuitem, menuitemcheckbox, menuitemradio, groups and separators, so a text field or button placed among the rows is invalid structure. Teaching the menus' key handling to step aside for those controls made that structure work instead of fixing it. Removes the hosted-control key handling from DropdownMenu, ContextMenu and the sub-menu flyout, the HostedField story and its tests, the FR12 and FR8 rows it added to the DropdownMenu and ContextMenu records, and its pending changeset. Unreleased, so no caller is affected. Controls that belong beside a menu's rows go outside the role="menu" element; a header/footer region for that follows separately. Original change by vjeux. * chore: changeset for the menu hosted-control revert
User impact
A field a menu hosts beside its rows, such as a filter, cannot be typed in: each letter moves focus to a matching row, and Space then picks it. Home, End and the arrows rove the rows, and a hosted button cannot be pressed from the keyboard. ContextMenu and sub-menu flyouts share this.
Problem and solution fit
A key pressed in a control the menu hosts outside every row is now that control's.
Expected behavior and authority
architecture:interaction-modality(current) INV4: every modality has an operable path.component:DropdownMenuandcomponent:ContextMenuare drafts; this PR amends their keyboard rows (FR12, FR8).Smallest restoration
useListFocus's existing caret guard, so arrows, Home and End leave a text field only at the edge of its text.Rows, Tab and Escape are unchanged; a control inside a row still belongs to the row. No API or default change.
Evidence
main(the Escape and typeahead guard passes); both Chromium cases fail against amainbuild.Writing rubric results
R1 narration: FR12 and FR8 are present tense.
R2 research: none.
R3 evidence: the verification rows name the tests.
R4 rejected alternatives: none.
R5 change references: none.
R6 open questions: none.
Scope
Testing