Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
74c13f0
feat(react-headless-components-preview): match v9 focus behavior with…
dmytrokirpa Oct 28, 2026
ea5c1c0
chore(react-headless-components-preview): drop TagPicker and Teaching…
dmytrokirpa Oct 28, 2026
7b71840
Merge remote-tracking branch 'upstream/master' into claude/react-tabs…
dmytrokirpa Oct 28, 2026
4c2fc23
refactor(react-headless-components-preview): rely on an application l…
dmytrokirpa Oct 28, 2026
b1f64f4
refactor(react-headless-components-preview): use static focusgroup at…
dmytrokirpa Oct 28, 2026
ca9992e
Merge remote-tracking branch 'upstream/master' into claude/react-tabs…
dmytrokirpa Oct 29, 2026
347f2b5
chore(react-headless-components-preview): regenerate teaching-popover…
dmytrokirpa Oct 29, 2026
3341de4
refactor(react-headless-components-preview): rename hooks/focusgroup …
dmytrokirpa Oct 29, 2026
b5bb189
Merge branch 'master' into claude/react-tabster-reimplementation-a645ee
dmytrokirpa Oct 29, 2026
de6d745
Merge branch 'master' into claude/react-tabster-reimplementation-a645ee
dmytrokirpa Oct 29, 2026
8199053
refactor(react-headless-components-preview): keep only the focus hook…
dmytrokirpa Oct 29, 2026
6cf6dc3
Merge branch 'claude/react-tabster-reimplementation-a645ee' of https:…
dmytrokirpa Oct 29, 2026
efa42d1
feat(react-headless-components-preview): match styled focus behavior …
dmytrokirpa Oct 29, 2026
a5e5641
chore(react-headless-components-preview): regenerate tag-group API re…
dmytrokirpa Oct 29, 2026
4193143
Merge remote-tracking branch 'upstream/master' into claude/react-tabs…
dmytrokirpa Nov 9, 2026
3bcfcc1
fix(react-headless-components-preview): address focus review feedback
dmytrokirpa Nov 9, 2026
2a73db1
Merge branch 'master' into claude/react-tabster-reimplementation-a645ee
dmytrokirpa Nov 12, 2026
5dfcce5
fix(react-headless-components-preview): address second round of focus…
dmytrokirpa Nov 12, 2026
4e29890
Merge branch 'master' into claude/react-tabster-reimplementation-a645ee
dmytrokirpa Nov 18, 2026
b1a57ee
Merge remote-tracking branch 'refs/remotes/upstream/master' into clau…
dmytrokirpa Nov 23, 2026
99d2689
refactor(react-headless-components-preview): split the focus manager …
dmytrokirpa Nov 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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.

"type": "minor",
"comment": "feat: match v9 focus behavior: Tab cycling focus trap in Dialog and Drawer (opt out with inertTrapFocus), Card focusMode, Breadcrumb arrow navigation, NavDrawerBody and TeachingPopoverCarouselNav arrow navigation, MenuSplitGroup inline arrow keys, TagGroup focus after dismiss, Toast keyboard navigation (Tab into and within a toast, wrapping ArrowUp/ArrowDown between toasts); TagPicker skips disabled or hidden tags when moving focus from the input",
"packageName": "@fluentui/react-headless-components-preview",
"email": "kirpadv@gmail.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ global.ResizeObserver = class ResizeObserver {
// no-op for jsdom
}
};
// JSDOM has no layout, so `getClientRects()` is always empty and the focus finders would treat every element
// as hidden. Report elements as visible unless a test overrides it.
if (typeof HTMLElement !== 'undefined' && !HTMLElement.prototype.checkVisibility) {
HTMLElement.prototype.checkVisibility = function checkVisibility() {
return true;
};
}

// JSDOM does not implement native <dialog> APIs yet.
// Provide a minimal test shim so components using showModal/show/close can run in Jest.
if (typeof HTMLDialogElement !== 'undefined') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { renderBreadcrumb_unstable as renderBreadcrumb } from '@fluentui/react-b
import { renderBreadcrumbButton_unstable as renderBreadcrumbButton } from '@fluentui/react-breadcrumb';
import { renderBreadcrumbDivider_unstable as renderBreadcrumbDivider } from '@fluentui/react-breadcrumb';
import { renderBreadcrumbItem_unstable as renderBreadcrumbItem } from '@fluentui/react-breadcrumb';
import { useBreadcrumbBase_unstable as useBreadcrumb } from '@fluentui/react-breadcrumb';
import { useBreadcrumbContext_unstable as useBreadcrumbContext } from '@fluentui/react-breadcrumb';
import { useBreadcrumbDividerBase_unstable as useBreadcrumbDivider } from '@fluentui/react-breadcrumb';
import { useBreadcrumbItemBase_unstable as useBreadcrumbItem } from '@fluentui/react-breadcrumb';
Expand Down Expand Up @@ -79,7 +78,8 @@ export { renderBreadcrumbDivider }

export { renderBreadcrumbItem }

export { useBreadcrumb }
// @public
export const useBreadcrumb: (props: BreadcrumbProps, ref: React_2.Ref<HTMLElement>) => BreadcrumbState;

// @public
export const useBreadcrumbButton: (props: BreadcrumbButtonProps, ref: React_2.Ref<HTMLButtonElement | HTMLAnchorElement>) => BreadcrumbButtonState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

```ts

import type { CardBaseProps } from '@fluentui/react-card';
import type { CardBaseState } from '@fluentui/react-card';
import { CardContextValue } from '@fluentui/react-card';
import { CardFooterBaseProps as CardFooterProps } from '@fluentui/react-card';
Expand All @@ -17,9 +16,10 @@ import { CardOnSelectionChangeEvent } from '@fluentui/react-card';
import { CardPreviewBaseProps as CardPreviewProps } from '@fluentui/react-card';
import { CardPreviewSlots } from '@fluentui/react-card';
import { CardPreviewBaseState as CardPreviewState } from '@fluentui/react-card';
import { CardBaseProps as CardProps } from '@fluentui/react-card';
import { CardSlots } from '@fluentui/react-card';
import type { ForwardRefComponent } from '@fluentui/react-utilities';
import type * as React_2 from 'react';
import * as React_2 from 'react';
import { renderCard_unstable as renderCard } from '@fluentui/react-card';
import { renderCardFooter_unstable as renderCardFooter } from '@fluentui/react-card';
import { renderCardHeader_unstable as renderCardHeader } from '@fluentui/react-card';
Expand Down Expand Up @@ -63,8 +63,7 @@ export { CardPreviewSlots }

export { CardPreviewState }

// @public
export type CardProps = Omit<CardBaseProps, 'focusMode'>;
export { CardProps }

export { CardSlots }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export type InlineDrawerState = InlineDrawerBaseState & {
export const OverlayDrawer: ForwardRefComponent<OverlayDrawerProps>;

// @public (undocumented)
export type OverlayDrawerProps = ComponentProps<OverlayDrawerSlots> & Pick<OverlayDrawerProps_2, 'position'> & Pick<DialogProps, 'open' | 'modalType' | 'onOpenChange' | 'unmountOnClose'>;
export type OverlayDrawerProps = ComponentProps<OverlayDrawerSlots> & Pick<OverlayDrawerProps_2, 'position'> & Pick<DialogProps, 'open' | 'modalType' | 'onOpenChange' | 'unmountOnClose' | 'inertTrapFocus'>;

// @public (undocumented)
export type OverlayDrawerSlots = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
```ts

import type { ForwardRefComponent } from '@fluentui/react-utilities';
import type * as React_2 from 'react';
import * as React_2 from 'react';
import { renderTagGroup_unstable as renderTagGroup } from '@fluentui/react-tags';
import type { TagGroupBaseState } from '@fluentui/react-tags';
import { TagGroupContextValue } from '@fluentui/react-tags';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import { useTeachingPopoverCarouselBase_unstable as useTeachingPopoverCarousel }
import { useTeachingPopoverCarouselCard_unstable as useTeachingPopoverCarouselCard } from '@fluentui/react-teaching-popover';
import type { useTeachingPopoverCarouselContextValues_unstable } from '@fluentui/react-teaching-popover';
import { useTeachingPopoverCarouselFooterButtonBase_unstable as useTeachingPopoverCarouselFooterButton } from '@fluentui/react-teaching-popover';
import { useTeachingPopoverCarouselNavBase_unstable as useTeachingPopoverCarouselNav } from '@fluentui/react-teaching-popover';
import { useTeachingPopoverCarouselPageCount_unstable as useTeachingPopoverCarouselPageCount } from '@fluentui/react-teaching-popover';
import { useTeachingPopoverFooterBase_unstable as useTeachingPopoverFooter } from '@fluentui/react-teaching-popover';
import { useTeachingPopoverHeaderBase_unstable as useTeachingPopoverHeader } from '@fluentui/react-teaching-popover';
Expand Down Expand Up @@ -327,7 +326,8 @@ export const useTeachingPopoverCarouselFooter: (props: TeachingPopoverCarouselFo

export { useTeachingPopoverCarouselFooterButton }

export { useTeachingPopoverCarouselNav }
// @public
export const useTeachingPopoverCarouselNav: (props: TeachingPopoverCarouselNavProps, ref: React_2.Ref<HTMLDivElement>) => TeachingPopoverCarouselNavState;

// @public (undocumented)
export const useTeachingPopoverCarouselNavButton: (props: TeachingPopoverCarouselNavButtonProps, ref: React_2.Ref<HTMLButtonElement | HTMLAnchorElement>) => TeachingPopoverCarouselNavButtonState;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
'use client';

import { useBreadcrumbContextValues_unstable } from '@fluentui/react-breadcrumb';
import type * as React from 'react';
import { useBreadcrumbBase_unstable, useBreadcrumbContextValues_unstable } from '@fluentui/react-breadcrumb';

import type { BreadcrumbState, BreadcrumbContextValues } from './Breadcrumb.types';
import type { BreadcrumbProps, BreadcrumbState, BreadcrumbContextValues } from './Breadcrumb.types';

/**
* Returns the state for a Breadcrumb component, given its props and ref.
* The returned state can be modified with hooks before being passed to `renderBreadcrumb`.
*/
export { useBreadcrumbBase_unstable as useBreadcrumb } from '@fluentui/react-breadcrumb';
export const useBreadcrumb = (props: BreadcrumbProps, ref: React.Ref<HTMLElement>): BreadcrumbState => {
const state: BreadcrumbState = useBreadcrumbBase_unstable(props, ref);

if (props.focusMode === 'arrow' && state.root.focusgroup === undefined) {
// eslint-disable-next-line react-hooks/immutability
state.root.focusgroup = 'toolbar inline wrap';
}

return state;
};

/**
* Returns the context values provided by the nearest Breadcrumb, enabling child components to
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import type { CardBaseProps, CardBaseState } from '@fluentui/react-card';
import type { CardBaseState } from '@fluentui/react-card';

export type { CardSlots, CardContextValue, CardOnSelectionChangeEvent } from '@fluentui/react-card';

/**
* Card component props
*
* Note: `focusMode` is intentionally omitted in the headless package because
* its tabster groupper-style Tab-trap semantics (limited / limited-trap-focus
* / unlimited) cannot be expressed with the WICG `focusgroup` polyfill that
* the headless components rely on. Consumers can implement equivalent
* behavior themselves on top of the rendered DOM.
*/
export type CardProps = Omit<CardBaseProps, 'focusMode'>;
export type {
CardBaseProps as CardProps,
CardSlots,
CardContextValue,
CardOnSelectionChangeEvent,
} from '@fluentui/react-card';

/**
* Card component state
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,67 @@
'use client';

import type * as React from 'react';
import * as React from 'react';
import { useCardBase_unstable } from '@fluentui/react-card';
import type { CardOnSelectionChangeEvent } from '@fluentui/react-card';
import { mergeCallbacks, useMergedRefs } from '@fluentui/react-utilities';

import type { CardContextValue, CardProps, CardState } from './Card.types';
import { toDataAttributeValue } from '../../utils/toDataAttributeValue';
import { findAllFocusable, useFocusableGroup } from '../../hooks/focus';
import type { UseFocusableGroupOptions } from '../../hooks/focus';

const focusMap: Record<NonNullable<CardProps['focusMode']>, UseFocusableGroupOptions['tabBehavior'] | undefined> = {
off: undefined,
'no-tab': 'limited-trap-focus',
'tab-exit': 'limited',
'tab-only': 'unlimited',
};

const interactiveEventProps = [
'onClick',
'onDoubleClick',
'onMouseUp',
'onMouseDown',
'onPointerUp',
'onPointerDown',
'onTouchStart',
'onTouchEnd',
'onDragStart',
'onDragEnd',
] as const;

const isInteractive = (props: CardProps): boolean =>
!props.disabled && interactiveEventProps.some(prop => props[prop] !== undefined);

/**
* Returns the state for a Card component, given its props and ref.
* The returned state can be modified with hooks before being passed to `renderCard`.
*/
export const useCard = (props: CardProps, ref: React.Ref<HTMLDivElement>): CardState => {
const state: CardState = useCardBase_unstable(props, ref);
const { focusMode: focusModeProp, disabled = false } = props;
const cardRef = React.useRef<HTMLDivElement>(null);
const mergedRef = useMergedRefs(cardRef, ref);

// Interacting with an inner focusable element must not toggle the card's selection.
const shouldRestrictTriggerAction = React.useCallback((event: CardOnSelectionChangeEvent) => {
const target = event.target as HTMLElement;
return !!cardRef.current && findAllFocusable(cardRef.current).some(element => element.contains(target));
}, []);

const focusMode = focusModeProp ?? (isInteractive(props) ? 'no-tab' : 'off');
const { onKeyDown: onGroupKeyDown, ...focusableGroupAttributes } = useFocusableGroup({
tabBehavior: focusMap[focusMode],
});

const state: CardState = useCardBase_unstable({ shouldRestrictTriggerAction, ...props }, mergedRef);

if (!disabled && !state.selectable && focusMode !== 'off') {
Object.assign(state.root, focusableGroupAttributes, {
tabIndex: 0,
// The consumer's handler runs first and can keep the group from handling Escape with `preventDefault()`.
onKeyDown: mergeCallbacks(state.root.onKeyDown, onGroupKeyDown),
});
}

// eslint-disable-next-line react-hooks/immutability
state.root['data-selected'] = toDataAttributeValue(state.selected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,13 @@ describe('Dialog', () => {

// Focus trap tests apply to modal/alert only — non-modal is intentionally not trapped.
if (modalType !== 'non-modal') {
// TODO: re-enable skipped test after introducing focus trap implementation
it.skip('should focus trap by default', () => {
it('should focus trap by default', () => {
mount(<BasicDialog modalType={modalType} />);
cy.get(dialogTriggerOpenSelector).realClick();
cy.get(dialogTriggerCloseSelector).should('be.focused').realPress('Tab');
cy.get(dialogPrimaryButtonSelector).should('be.focused').realPress('Tab');
cy.get(dialogTriggerCloseSelector).should('be.focused');
cy.get(dialogTriggerCloseSelector).should('be.focused').realPress(['Shift', 'Tab']);
cy.get(dialogPrimaryButtonSelector).should('be.focused');
});

it.skip('should keep focus trapped when inertTrapFocus=true', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export type DialogProps = {

/**
* Enables standard behavior according to the HTML dialog spec
* where the focus trap involves setting outside elements inert.
* Native `<dialog showModal()>` always uses inert focus trapping,
* so this prop is accepted for API parity but does not change behavior.
* where the focus trap involves setting outside elements inert,
* letting Tab move from the dialog to the browser UI and back.
* By default, Tab and Shift+Tab cycle inside modal and alert dialogs.
*
* @default false
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as React from 'react';
import { useFluent_unstable as useFluent } from '@fluentui/react-shared-contexts';
import { slot, useMergedRefs, useEventCallback, useIsomorphicLayoutEffect } from '@fluentui/react-utilities';
import { useDialogContext } from '../dialogContext';
import { useModalAttributes } from '../../../hooks/focus';
import { toDataAttributeValue } from '../../../utils';
import { lockDocumentScroll, unlockDocumentScroll } from '../utils/scroll';
import { useDialogLayerOpenState, useLayerEscape, useLayerPresence } from '../../../hooks/top-layer';
Expand All @@ -17,8 +18,12 @@ import type { DialogSurfaceProps, DialogSurfaceState } from './DialogSurface.typ
* @param ref - reference to root HTMLDialogElement of DialogSurface
*/
export const useDialogSurface = (props: DialogSurfaceProps, ref: React.Ref<HTMLDialogElement>): DialogSurfaceState => {
const { open, modalType, unmountOnClose, requestOpenChange, dialogTitleId } = useDialogContext();
const { open, modalType, unmountOnClose, requestOpenChange, dialogTitleId, inertTrapFocus } = useDialogContext();
const { targetDocument } = useFluent();
const { modalAttributes } = useModalAttributes({
trapFocus: modalType !== 'non-modal',
legacyTrapFocus: !inertTrapFocus,
});

const dialogRef = React.useRef<HTMLDialogElement>(null);
const mergedRef = useMergedRefs(ref, dialogRef);
Expand Down Expand Up @@ -120,6 +125,7 @@ export const useDialogSurface = (props: DialogSurfaceProps, ref: React.Ref<HTMLD
role: modalType === 'alert' ? 'alertdialog' : undefined,
'aria-modal': modalType !== 'non-modal' ? true : undefined,
'aria-labelledby': props['aria-label'] ? undefined : dialogTitleId || undefined,
...modalAttributes,
...props,
tabIndex: -1,
ref: mergedRef,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type OverlayDrawerInternalSlots = OverlayDrawerSlots & {

export type OverlayDrawerProps = ComponentProps<OverlayDrawerSlots> &
Pick<OverlayDrawerBaseProps, 'position'> &
Pick<DialogProps, 'open' | 'modalType' | 'onOpenChange' | 'unmountOnClose'>;
Pick<DialogProps, 'open' | 'modalType' | 'onOpenChange' | 'unmountOnClose' | 'inertTrapFocus'>;

export type OverlayDrawerState = ComponentState<OverlayDrawerInternalSlots> &
Required<Pick<OverlayDrawerProps, 'open' | 'position' | 'unmountOnClose' | 'modalType'>> &
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const useOverlayDrawer = (props: OverlayDrawerProps, ref: React.Ref<HTMLD
unmountOnClose = true,
modalType = 'modal',
onOpenChange,
inertTrapFocus,
...rootProps
} = props;

Expand All @@ -37,6 +38,7 @@ export const useOverlayDrawer = (props: OverlayDrawerProps, ref: React.Ref<HTMLD
onOpenChange,
modalType,
unmountOnClose,
inertTrapFocus,
/**
* children is not needed here because we construct the children in the render function,
* but it's required by DialogProps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ import { useInteractionTagBase_unstable } from '@fluentui/react-tags';
import type { InteractionTagProps, InteractionTagState } from './InteractionTag.types';
import { toDataAttributeValue } from '../../utils';

/**
* Marks the root of an InteractionTag so TagGroup can tell which focusable elements are dismissed together.
*
* @internal
*/
export const INTERACTION_TAG_ATTRIBUTE = 'data-fui-interaction-tag';

/**
* Returns the state for an InteractionTag component, given its props and ref.
* The returned state can be modified with hooks before being passed to `renderInteractionTag`.
Expand All @@ -17,6 +24,7 @@ export const useInteractionTag = (props: InteractionTagProps, ref: React.Ref<HTM
state.root['data-disabled'] = toDataAttributeValue(state.disabled);
state.root['data-selected'] = toDataAttributeValue(state.selected);
/* eslint-enable react-hooks/immutability */
Object.assign(state.root, { [INTERACTION_TAG_ATTRIBUTE]: '' });

return state;
};
Loading
Loading