Repository navigation
feat(react-headless-components-preview): match v9 focus behavior without react-tabster - #37027
Draft
Dmytro Kirpa (dmytrokirpa) wants to merge 21 commits into
Draft
Dmytro Kirpa (dmytrokirpa) wants to merge 21 commits into
Dmytro Kirpa (dmytrokirpa) wants to merge 21 commits into
Conversation
…out react-tabster - Tab cycling focus trap in Dialog, Drawer and Popover (opt out with inertTrapFocus) - Card focusMode via an internal focusable group - arrow navigation for Breadcrumb, NavDrawerBody and TeachingPopoverCarouselNav - internal useArrowNavigationGroup returns focusgroup attributes plus a ref that applies @microsoft/focusgroup-polyfill to the component's own element - Tooltip tracks keyboard/pointer input without keyborg - drop the @fluentui/react-tabster dependency Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…Popover bundle-size fixtures
…ter-reimplementation-a645ee # Conflicts: # packages/react-components/react-headless-components-preview/library/bundle-size/TagPicker.fixture.js # packages/react-components/react-headless-components-preview/library/bundle-size/TeachingPopover.fixture.js
…evel focusgroup polyfill useArrowNavigationGroup returns only the focusgroup attribute again, and the package no longer depends on @microsoft/focusgroup-polyfill.
📊 Bundle size reportUnchanged fixtures
|
|
Pull request demo site: URL |
| @@ -0,0 +1,7 @@ | |||
| { | |||
There was a problem hiding this comment.
🕵🏾♀️ visual changes to review in the Visual Change Report
vr-tests-web-components/TextInput 1 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests-web-components/TextInput. - Dark Mode.normal.chromium_1.png | 288 | Changed |
vr-tests/Callout 1 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests/Callout.No callout width specified.default.chromium.png | 2143 | Changed |
vr-tests/react-charting-LineChart 3 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests/react-charting-LineChart.Multiple - RTL.default.chromium.png | 200 | Changed |
| vr-tests/react-charting-LineChart.Multiple - Dark Mode.default.chromium.png | 181 | Changed |
| vr-tests/react-charting-LineChart.Multiple.default.chromium.png | 192 | Changed |
vr-tests/react-charting-MultiStackBarChart 4 screenshots
| Image Name | Diff(in Pixels) | Image Type |
|---|---|---|
| vr-tests/react-charting-MultiStackBarChart.Basic_Absolute - Dark Mode.default.chromium.png | 363 | Changed |
| vr-tests/react-charting-MultiStackBarChart.Basic_PartToWhole - Dark Mode.default.chromium.png | 363 | Changed |
| vr-tests/react-charting-MultiStackBarChart.Basic_PartToWhole - RTL.default.chromium.png | 343 | Changed |
| vr-tests/react-charting-MultiStackBarChart.Basic_Absolute - RTL.default.chromium.png | 343 | Changed |
There were 1 duplicate changes discarded. Check the build logs for more information.
…tributes Remove the internal useArrowNavigationGroup hook; components set their focusgroup values directly. Use @testing-library/react-hooks for renderHook so the focus hook tests run on React 17.
…ter-reimplementation-a645ee Adopt upstream's Popover inertTrapFocus API (microsoft#37024), dropping this branch's separate trapFocus + Tab-cycling trap on PopoverSurface. Also finish the rename in PopoverTrigger and InfoButton, which still read trapFocus after microsoft#36953.
…s this PR needs Leave keyboard modality and the Tooltip keyborg replacement to microsoft#36897: restore master's Tooltip and react-tabster dependency, and drop the custom keyboard tracker. Remove the unused useFocusFinders wrapper, finder helpers, triggerAttributes and ignoreDefaultKeydown. Restore the TagPicker and TeachingPopover bundle-size fixtures.
…//github.com/dmytrokirpa/fluentui into claude/react-tabster-reimplementation-a645ee
…in TagGroup, MenuSplitGroup, TagPicker and Toast - restore the internal focus finders and the focusable group ignoreDefaultKeydown option - TagGroup moves focus to the next (or previous) tag when the focused tag is dismissed - MenuSplitGroup moves focus between its items with the inline arrow keys - TagPicker skips disabled or hidden tags when moving focus from the input - Toast: Tab enters a toast and stays inside it, ArrowUp/ArrowDown wrap between toasts, replacing the focusgroup arrow model - shim checkVisibility for jsdom in the shared Jest setup
…ter-reimplementation-a645ee # Conflicts: # packages/react-components/react-headless-components-preview/library/src/components/Menu/Menu.test.tsx
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved keyboard-navigation defects can break focus trapping, bypass Card entry restrictions, and override child controls or consumer handlers.
9 open issues
Compose consumer and internal keydown handlers · New Skip the parent only for InteractionTag secondary actions · New Honor defaultPrevented before wrapping Tab focus · New Preserve arrow-key behavior in editable toast content · New Prevent page scrolling during toast arrow navigation · New Exclude controls disabled by an ancestor fieldset · New Respect native radio-group Tab stops · New Use native tab order when detecting dialog boundaries · New Prevent Tab from entering unentered Card descendants · New
What changed in this PR
This PR brings headless components closer to Fluent UI v9 keyboard behavior using internal DOM-based focus management rather than react-tabster.
Changes:
- Adds modal Tab cycling, Card focus modes, and shared focus-finding utilities.
- Adds or updates keyboard navigation for breadcrumbs, navigation drawers, teaching popovers, menus, tags, and toasts.
- Adds regression tests, updates public API reports, and records the feature release.
| File | Description |
|---|---|
| tools/workspace-plugin/src/generators/bundle-size-fixtures-sync/index.ts | Formatting only. |
| tools/workspace-plugin/src/generators/bundle-size-fixtures-sync/index.spec.ts | Quote-style formatting only. |
| packages/react-components/react-headless-components-preview/library/src/utils/tagFocusUtils.ts | Uses shared focus finders for tags. |
| packages/react-components/react-headless-components-preview/library/src/utils/tagFocusUtils.test.ts | Tests skipping disabled tags. |
| packages/react-components/react-headless-components-preview/library/src/hooks/focus/useModalAttributes.ts | Supplies modal focus-trap attributes. |
| packages/react-components/react-headless-components-preview/library/src/hooks/focus/useFocusableGroup.ts | Supplies focusable-group behavior attributes. |
| packages/react-components/react-headless-components-preview/library/src/hooks/focus/index.ts | Exposes internal focus helpers. |
| packages/react-components/react-headless-components-preview/library/src/hooks/focus/focusManager.ts | Implements document-level trap and group navigation. |
| packages/react-components/react-headless-components-preview/library/src/hooks/focus/focusFinders.ts | Adds focusability checks and element traversal. |
| packages/react-components/react-headless-components-preview/library/src/hooks/focus/focus.test.tsx | Tests focus traps and groups. |
| packages/react-components/react-headless-components-preview/library/src/hooks/focus/focus.cy.tsx | Tests component keyboard interactions in-browser. |
| packages/react-components/react-headless-components-preview/library/src/components/Toast/useToast.ts | Removes the toast focusgroup override. |
| packages/react-components/react-headless-components-preview/library/src/components/Toast/Toaster/useToaster.tsx | Adds wrapping arrow navigation between toasts. |
| packages/react-components/react-headless-components-preview/library/src/components/Toast/Toaster/Toaster.test.tsx | Updates list and tab-stop assertions. |
| packages/react-components/react-headless-components-preview/library/src/components/Toast/ToastContainer/useToastContainer.ts | Adds Tab navigation within toasts. |
| packages/react-components/react-headless-components-preview/library/src/components/Toast/Toast.test.tsx | Removes the obsolete focusgroup assertion. |
| packages/react-components/react-headless-components-preview/library/src/components/Toast/Toast.cy.tsx | Tests arrow wrapping and Tab cycling. |
| packages/react-components/react-headless-components-preview/library/src/components/TeachingPopover/TeachingPopoverCarouselNavButton/useTeachingPopoverCarouselNavButton.ts | Marks the selected navigation entry point. |
| packages/react-components/react-headless-components-preview/library/src/components/TeachingPopover/TeachingPopoverCarouselNav/useTeachingPopoverCarouselNav.ts | Adds inline arrow-navigation attributes. |
| packages/react-components/react-headless-components-preview/library/src/components/TagGroup/useTagGroup.ts | Moves focus after tag dismissal. |
| packages/react-components/react-headless-components-preview/library/src/components/TagGroup/TagGroup.test.tsx | Tests focus movement after dismissal. |
| packages/react-components/react-headless-components-preview/library/src/components/Nav/NavDrawerBody/useNavDrawerBody.ts | Adds wrapping block-axis navigation. |
| packages/react-components/react-headless-components-preview/library/src/components/Menu/MenuSplitGroup/useMenuSplitGroup.ts | Adds direction-aware split-item navigation. |
| packages/react-components/react-headless-components-preview/library/src/components/Menu/Menu.test.tsx | Tests split-item arrow navigation. |
| packages/react-components/react-headless-components-preview/library/src/components/Drawer/OverlayDrawer/useOverlayDrawer.ts | Forwards the native-only trap option. |
| packages/react-components/react-headless-components-preview/library/src/components/Drawer/OverlayDrawer/OverlayDrawer.types.ts | Exposes inertTrapFocus. |
| packages/react-components/react-headless-components-preview/library/src/components/Dialog/DialogSurface/useDialogSurface.ts | Applies modal focus-trap attributes. |
| packages/react-components/react-headless-components-preview/library/src/components/Dialog/Dialog.types.ts | Documents default cycling and native-only trapping. |
| packages/react-components/react-headless-components-preview/library/src/components/Dialog/Dialog.cy.tsx | Enables and extends focus-trap coverage. |
| packages/react-components/react-headless-components-preview/library/src/components/Card/useCard.ts | Implements focus modes and guards selection interactions. |
| packages/react-components/react-headless-components-preview/library/src/components/Card/Card.types.ts | Restores focusMode in Card props. |
| packages/react-components/react-headless-components-preview/library/src/components/Breadcrumb/useBreadcrumb.ts | Adds arrow-mode focusgroup attributes. |
| packages/react-components/react-headless-components-preview/library/etc/teaching-popover.api.md | Updates the carousel navigation hook report. |
| packages/react-components/react-headless-components-preview/library/etc/tag-group.api.md | Reflects the React import change. |
| packages/react-components/react-headless-components-preview/library/etc/drawer.api.md | Records inertTrapFocus in drawer props. |
| packages/react-components/react-headless-components-preview/library/etc/card.api.md | Records restored Card props. |
| packages/react-components/react-headless-components-preview/library/etc/breadcrumb.api.md | Records the local Breadcrumb hook signature. |
| packages/react-components/react-headless-components-preview/library/config/tests.cjs | Adds a visibility shim for focus tests. |
| change/@fluentui-react-headless-components-preview-focusgroup-hooks.json | Records a minor release for focus features. |
Review effort: Balanced
- focus finders: treat fieldset-disabled controls as disabled, keep one Tab stop per native radio group, and follow positive tabindex order - focus manager: pick trap boundaries from the native Tab order, and keep Tab from entering an unentered limited group at the end of the page - MenuSplitGroup composes a consumer onKeyDown instead of being overridden by it - TagGroup only skips the dismissed InteractionTag's own primary action - Toast leaves Tab and arrow keys already handled by its content, and editable controls, alone; arrow navigation no longer scrolls the page
Dmytro Kirpa (dmytrokirpa)
requested review from
Paul Mardling (PaulGMardling) and
Victor Genaev (mainframev)
November 12, 2026 20:54
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
A critical focus-trap defect lets Tab escape dialogs rendered in open shadow roots, alongside unresolved focus-navigation and keyboard-handling issues.
6 open issues
Resolve focused controls inside open shadow roots · New Prevent default scrolling when handling split-item arrow keys · New Identify dismissed tags without relying on overridable aria labels · New Exclude hidden controls in the visibility fallback · New Resolve enclosing group when Escape starts on the active group · New Handle group Escape after descendant widgets can consume it · New
9 resolved since last review
Prevent Tab from entering unentered Card descendants Use native tab order when detecting dialog boundaries Respect native radio-group Tab stops Exclude controls disabled by an ancestor fieldset Prevent page scrolling during toast arrow navigation Preserve arrow-key behavior in editable toast content Honor defaultPrevented before wrapping Tab focus Skip the parent only for InteractionTag secondary actions Compose consumer and internal keydown handlers
Review effort: Balanced
… review feedback - focus manager follows focus into open shadow roots - focusable group Escape runs as the group's own onKeyDown, after descendants and before ancestors, and nested groups exit one level at a time - MenuSplitGroup prevents the default scroll of handled arrow keys - the visibility fallback rejects visibility: hidden and collapse - TagGroup identifies a dismissed InteractionTag by a component-owned marker
Dmytro Kirpa (dmytrokirpa)
marked this pull request as draft
November 19, 2026 14:53
…de/react-tabster-reimplementation-a645ee # Conflicts: # packages/react-components/react-headless-components-preview/library/src/components/Menu/MenuSplitGroup/useMenuSplitGroup.ts # packages/react-components/react-headless-components-preview/library/src/components/Toast/ToastContainer/useToastContainer.ts # packages/react-components/react-headless-components-preview/library/src/components/Toast/Toaster/useToaster.tsx
…into trap and group handlers Dialog, Drawer and Nav only bundle the focus trap; the focusable group code (Enter, Escape, limited groups, page boundary) is only bundled where useFocusableGroup is used.
This branch has not been deployed
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.



Previous Behavior
Headless components depended on
@fluentui/react-tabster/ keyborg for a few behaviors and lacked others v9 has:showModal()), so Tab escaped to the browser chrome instead of cycling inside the surface.focusMode.focusMode="arrow", NavDrawerBody and TeachingPopoverCarouselNav had no arrow navigation.New Behavior
Internal (not exported) focus hooks under
src/hooks/focusgroup, named after their react-tabster counterparts but returning plain DOM props instead ofdata-tabster:useModalAttributes: Tab/Shift+Tab cycle inside Dialog, Drawer and Popover surfaces by default, like v9.inertTrapFocusopts into the native-only trap (new prop on Popover and OverlayDrawer).useFocusableGroup: CardfocusMode(no-tab,tab-exit,tab-only) with Enter/Escape group navigation.focusMode="arrow", NavDrawerBody and TeachingPopoverCarouselNav set staticfocusgroupattributes (the application installs@microsoft/focusgroup-polyfillglobally, as for the other headless components).useFocusFinders.@fluentui/react-tabsterdependency.Bundle size (minified)
Without the polyfill bundled, the added cost is the focus-trap and focusable-group logic: roughly +3.6–3.7 KB for Dialog/Drawer/Popover and +5.0 KB for Card, while Tooltip shrinks by ~2.8 KB after dropping keyborg. The TagPicker and TeachingPopover bundle-size fixtures are removed.
Known follow-ups
connect()/dispose and item-collection hooks in the polyfill: focusgroup: scoped connect() with a disposer, exported item collections, and no side effects on import polyfills#79.Related Issue(s)