fix(core): use roving tabindex in TabList overflow menu#3728
Merged
Conversation
|
@bhamodi is attempting to deploy a commit to the Meta Open Source Team on Vercel. A member of the Team first needs to authorize it. |
723fab2 to
bf66afb
Compare
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
cixzhang
approved these changes
Jul 10, 2026
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
The
TabMenuoverflow dropdown made every menu item a separate Tab stop: each item rendered withtabIndex={0}(TabMenu.tsx:374) anduseListFocuswas invoked withouthasRovingTabIndex(TabMenu.tsx:275-278). A keyboard user Tabbing through the open menu walked item-by-item instead of the APG menu pattern's single Tab stop with arrow-key navigation.This converts the menu to a roving tabindex, mirroring the established
useListFocus({hasRovingTabIndex: true})wiring inToolbar.tsx:245-250and the menu-button focus/close handling inDropdownMenu.tsx:hasRovingTabIndex: trueso the hook owns item tabindex -- exactly one enabled item istabIndex="0", the rest-1, and the stop follows arrow navigationtabIndex={-1}(the hook promotes one to the tab stop)handleFocusto the menu'sonFocusto keep the stop synced after clicks / programmatic focusrequestAnimationFrame(focusFirst)) so arrow keys work and the stop lands on a real item (previously focus stayed on the trigger, since the popover useshasAutoFocus: false)FOCUSABLE_SELECTORexcludestabindex="-1") would otherwise trap Tab on the single stop and leave the menu stuck open -- and add anonHidethat returns focus to the trigger, so Escape / Tab / select / light-dismiss never drop focus to<body>. This is the same wiringDropdownMenuuses.Selecting an overflow tab via click and Enter/Space, and Escape-to-close, are unchanged.
Changes
TabList/TabMenu.tsx:useListFocus({hasRovingTabIndex: true}); itemstabIndex={-1};onFocus={handleFocus}; focus-first on open; close-on-Tab;onHidereturns focus to the trigger.TabList/TabList.test.tsx: seven new tests underTabMenu keyboard navigation (roving tabindex).Test plan
node_modules/.bin/vitest run --root . packages/core/src/TabList-- 42 pass. Seven new tests:tabIndex="0"and Tab did not close). The arrow / Home/End / Enter / Escape tests passed both before and after -- focus movement and Escape already worked; the bug was tab-stop management, not navigation.node_modules/.bin/tsc --project packages/core/tsconfig.json --noEmit-- clean.node_modules/.bin/eslinton changed files -- clean.vitest run packages/core/src/DropdownMenu packages/core/src/ContextMenu packages/core/src/Toolbar packages/core/src/hooks/useListFocus.test.ts-- 111 pass. The shareduseListFocushook is unchanged, and no other core component embedsTabMenu.Notes
Found during an a11y audit; scoped to the roving-tabindex conversion plus the minimal focus-entry / Tab-out adjustments required to keep the menu usable under the new model. Typeahead is a separate finding and is not included here. No existing test encoded the buggy all-items-tabbable behavior, so none were weakened.
TabMenu.doc.mjs/TabList.doc.mjswere left unchanged: no props changed and neither documents the menu's internal tab-stop behavior.