Skip to content

feat(react-headless-components-preview): match v9 focus behavior without react-tabster - #37027

Draft
Dmytro Kirpa (dmytrokirpa) wants to merge 21 commits into
microsoft:masterfrom
dmytrokirpa:claude/react-tabster-reimplementation-a645ee
Draft

Dmytro Kirpa (dmytrokirpa) wants to merge 21 commits into
microsoft:masterfrom
dmytrokirpa:claude/react-tabster-reimplementation-a645ee

Conversation

@dmytrokirpa

@dmytrokirpa Dmytro Kirpa (dmytrokirpa) commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Previous Behavior

Headless components depended on @fluentui/react-tabster / keyborg for a few behaviors and lacked others v9 has:

  • Dialog, Drawer and Popover only had the native inert trap (showModal()), so Tab escaped to the browser chrome instead of cycling inside the surface.
  • Card ignored focusMode.
  • Breadcrumb 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 of data-tabster:

  • useModalAttributes: Tab/Shift+Tab cycle inside Dialog, Drawer and Popover surfaces by default, like v9. inertTrapFocus opts into the native-only trap (new prop on Popover and OverlayDrawer).
  • useFocusableGroup: Card focusMode (no-tab, tab-exit, tab-only) with Enter/Escape group navigation.
  • Breadcrumb focusMode="arrow", NavDrawerBody and TeachingPopoverCarouselNav set static focusgroup attributes (the application installs @microsoft/focusgroup-polyfill globally, as for the other headless components).
  • Keyboard-navigation tracking (Tooltip no longer shows on programmatic focus after a pointer interaction), and useFocusFinders.
  • Drops the @fluentui/react-tabster dependency.

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

Related Issue(s)

…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>
…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.
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-headless-components-preview
react-headless-components-preview: entire library
312.396 kB
94.45 kB
319.753 kB
96.874 kB
7.357 kB
2.424 kB
react-headless-components-preview
@fluentui/react-headless-components-preview/tag-picker
51.7 kB
16.97 kB
52.322 kB
17.215 kB
622 B
245 B
react-headless-components-preview
@fluentui/react-headless-components-preview/teaching-popover
35.831 kB
12.272 kB
35.959 kB
12.31 kB
128 B
38 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-headless-components-preview
react-headless-components-preview: Calendar
44.261 kB
14.657 kB
react-headless-components-preview
react-headless-components-preview: DatePicker
61.618 kB
20.336 kB
🤖 This report was generated against feab6ba63b55703d803f17092eab54c9dc82430b

@github-actions

Copy link
Copy Markdown

Pull request demo site: URL

@@ -0,0 +1,7 @@
{

@github-actions github-actions Bot Oct 28, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵🏾‍♀️ 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.
…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
Copilot AI balanced review requested due to automatic review settings November 9, 2026 17:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved keyboard-navigation defects can break focus trapping, bypass Card entry restrictions, and override child controls or consumer handlers.

9 open issues
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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

… 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
@dmytrokirpa
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
@github-actions github-actions Bot removed the NX: core label Nov 23, 2026
…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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants