Skip to content

fix(react-headless-components-preview): improve Toast focus accessibility - #36638

Open
Dmytro Kirpa (dmytrokirpa) wants to merge 3 commits into
microsoft:masterfrom
dmytrokirpa:headless-toast-focus-fix
Open

fix(react-headless-components-preview): improve Toast focus accessibility#36638
Dmytro Kirpa (dmytrokirpa) wants to merge 3 commits into
microsoft:masterfrom
dmytrokirpa:headless-toast-focus-fix

Conversation

@dmytrokirpa

Copy link
Copy Markdown
Contributor

Summary

  • add native focusgroup="toolbar block itemcontrols" navigation to headless toast stacks while preserving list/listitem semantics
  • exclude nested toast controls from outer directional navigation with focusgroup="none"
  • pause all toast timeouts while focus is inside a stack and resume them when focus leaves
  • add Jest and Cypress coverage for focusgroup attributes and focus-driven timeout behavior

Validation

  • yarn nx run react-headless-components-preview:lint
  • yarn nx run react-headless-components-preview:test --runTestsByPath src/components/Toast/Toast.test.tsx src/components/Toast/Toaster/Toaster.test.tsx --runInBand (25 tests passed)
  • yarn nx run react-headless-components-preview:e2e --spec "src/components/Toast/Toast.cy.tsx" (11 tests passed)
  • ./node_modules/.bin/beachball check

@dmytrokirpa
Dmytro Kirpa (dmytrokirpa) requested a review from a team as a code owner August 27, 2026 10:21
@github-actions

github-actions Bot commented Aug 27, 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
238.112 kB
67.048 kB
238.948 kB
67.28 kB
836 B
232 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-headless-components-preview
@fluentui/react-headless-components-preview/tag-picker
53.988 kB
17.748 kB
react-headless-components-preview
@fluentui/react-headless-components-preview/teaching-popover
36.048 kB
11.996 kB
🤖 This report was generated against 25b0646fa18bb93e2d7ed052379b852a1f45d8f4

@github-actions

Copy link
Copy Markdown

Pull request demo site: URL

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.

Pull request overview

Adds keyboard-accessible toast-stack navigation and focus-driven timeout pausing to the headless preview package.

Changes:

  • Adds native focusgroup attributes while preserving list semantics.
  • Pauses/resumes toast timers as focus enters/leaves a stack.
  • Adds unit, Cypress, and Beachball coverage.

Merge confidence: 55/100 due to unresolved timer edge cases and missing keyboard-navigation coverage.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
Toast/useToast.ts Excludes nested toast controls from outer focus navigation.
Toast/Toaster/useToaster.tsx Adds focusgroup navigation and focus-based timer handling.
Toast/Toaster/Toaster.test.tsx Tests stack focusgroup semantics.
Toast/Toast.test.tsx Tests nested focusgroup opt-out.
Toast/Toast.cy.tsx Tests focus-driven timeout behavior.
change/@fluentui-react-headless-components-preview-8f342829-73a2-4dc2-951d-9c89fcfe5321.json Records the patch release.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +64 to +67
const onFocus = useEventCallback((e: React.FocusEvent<HTMLDivElement>) => {
if (!e.currentTarget.contains(e.relatedTarget)) {
pauseAllToasts();
}
Comment on lines +70 to +73
const onBlur = useEventCallback((e: React.FocusEvent<HTMLDivElement>) => {
if (!e.currentTarget.contains(e.relatedTarget)) {
playAllToasts();
}
{toast.content as React.ReactNode}
</ToastContainer>
)),
focusgroup: 'toolbar block itemcontrols',

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.

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Comment on lines 82 to 85
const activeElement = targetDocument?.activeElement;
const containsActive = !!(activeElement && toastRef.current?.contains(activeElement));
const containsActive = !!(activeElement && toastRef.current?.parentElement?.contains(activeElement));
if (!containsActive) {
setRunning(true);
const pause = useEventCallback(() => setRunning(false));
const play = useEventCallback(() => {
if (imperativePauseRef.current) {
if (imperativePauseRef.current || hoverPauseRef.current || windowBlurPauseRef.current) {
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.

3 participants