Skip to content

fix(Toast): a Toast rendered on its own holds no live role - #11960

Merged
cixzhang merged 3 commits into
mainfrom
fix/toast-lone-card-no-live-role
Nov 19, 2026
Merged

cixzhang merged 3 commits into
mainfrom
fix/toast-lone-card-no-live-role

Conversation

@cixzhang

Copy link
Copy Markdown
Contributor

Fixes #11942

User impact

A screen-reader user can hear a Toast twice when an app renders it on its own (outside a ToastViewport) and also announces the message, for example through useAnnounce so it is read over an open modal. The card was a live region (role="status", or role="alert" for errors), so the card's own text was announced as well. After this change the card holds no live role, and its text stays readable in browse mode.

Problem and solution fit

  • Why it fails: the fix for [Bug] Toast: each toast has two live owners, and the body-level one goes silent over a Dialog #7853 took the live role off the cards a ToastViewport shows (the viewport passed isLiveRegion={false}). But isLiveRegion was an internal prop that defaulted to true, and the public Toast never set it, so a lone Toast kept role, aria-live and aria-atomic on its card.
  • The fix: the card never renders a live role. The internal isLiveRegion prop is removed; the viewport was its only other user, and it always passed false. The card reads and announces a component body or a custom layout only when the viewport hands it announce, so a Toast rendered on its own announces nothing. Its caller owns that announcement.

Expected behavior and authority

  • component:Toast FR9: "The card never holds a live role." The viewport is each shown toast's one announcement owner.
  • spec:AST-086 FR2 and FR3 list "toast card" under "no live element mounts holding its text".
  • No record changes. The status-message accessibility inventory still bound "Toast card" as a live region, which pinned the defect. That part moves to the inventory's exclusions, citing FR9, and its two Storybook states are removed.

Smallest restoration

  • Toast.tsx (no live attributes; the rendered-text announcement is gated on the viewport's announce), ToastViewport.tsx (the removed prop), and one sentence in Toast.doc.mjs: only the viewport announces a toast, and a Toast rendered on its own announces nothing.
  • No public API change: isLiveRegion was never part of ToastProps.
  • Changeset: @astryxdesign/core patch, [fix].

Evidence

  • Red first: the new Toast.standalone.test.tsx has three cases. Before the change, all 3 fail:
    • an info card and an error card on their own: no live element holds their text, and the text is visible;
    • a custom layout: no live element, and nothing written to the page's shared live regions.
  • After: 3 of 3 pass.
  • Unchanged paths: the viewport's announcement, modal-host, overwrite and focus suites pass, along with FieldStatus, the rendered-text adopters test, LayerProvider and ButtonGroup: 279 tests in 13 files.

Scope

Components: Toast

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • vitest run packages/core/src/Toast packages/core/src/FieldStatus …: all pass, with the new file red first as above.
  • tsc --noEmit -p packages/core: clean.
  • eslint (strict) on the changed files: no errors.
  • check:changesets: valid.

Thanks to @duytbp for the precise report.

Owner and land path

Owner: Cindy's Astryx gaps lane 3 (agent). Land path: Specs stamp as a defect repair, then CodeBunny review on the exact head, then ready, CI, and merge through the drain queue. Ships in the next patch release.

The viewport's cards already held no live role, but the public Toast kept role, aria-live and aria-atomic on its card, because the internal isLiveRegion prop defaulted to true. A caller that also announced the message had it read twice. The card now never renders a live role, and it announces a component body or custom layout only for the viewport, which passes announce. The status-message inventory moves the toast card to its exclusions. Reported by @duytbp.
@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 19, 2026 10:38am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 16, 2026
@astracat-bot

astracat-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 19, 2026, 11:29 AM UTC

@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 281f2e9

@github-actions

github-actions Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 9c2d401

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
FieldStatus · Storybook 10.5 kB (0) · 3.6 kB CSS (0) 163 (0) ✓ · ✓ · —
Toast · Storybook 106.4 kB (−62 B) · 11.2 kB CSS (0) 1,790 (−9) ✓ · ✓ · ✓

Package size: @astryxdesign/core 7.73 MB packed (−146 B); no new dependencies.

Touched components checked; for the full suites, add ci:run-visual for Visual, ci:run-rtl for RTL.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot Bot 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.

Approved. A Toast rendered on its own now carries no live role, as the Toast contract requires; the new tests fail before the change and pass after it, and CI passes on this head.

Optional follow-ups, none blocking: the usage text in Toast.doc.mjs (lines 92, 134 and 282) still says the card has role and live-region attributes, the new comment in Toast.tsx (lines 400–401) reads more easily as three short sentences, and the changeset could name role="status" and role="alert" so people whose tests query those roles on a lone card see why they stop matching.

Claims and files checked

Review mode: same-head; reason: none

  • Changed rules since the last review: none
  • Claims
    • A lone card was a live region (status or alert, with live and atomic attributes): verified in the base Toast.tsx.
    • The earlier viewport fix only opted viewport cards out through an internal prop that defaulted to on, which the public Toast never set: verified.
    • The card never renders a live role, the prop is removed, and the viewport was its only other source user: verified (one test also passed it and is updated).
    • The card announces a component body or custom layout only when the viewport hands it announce, so a lone Toast announces nothing: verified in Toast.tsx and by the custom-layout test.
    • The Toast record says the card never holds a live role, and the status-announcement record lists the toast card under "no live element mounts holding its text": verified on main.
    • No record changes; the inventory moves the toast card to its exclusions and drops its two stories: verified.
    • No public API change: verified (no API rows for any published package).
    • The changeset is a Core patch fix and is valid: verified.
    • All 3 new tests fail before the change and pass after: verified.
    • The viewport, modal-host, overwrite, focus, FieldStatus, adopter and Layer suites pass, and typecheck and lint are clean: verified, and CI passes on this head.
    • The card's text stays readable in browse mode: verified in Chromium's accessibility tree.
    • Nothing visual, no default and no interaction model changes: verified (identical frames, no API rows).
  • Files
    • .changeset/toast-lone-card-no-live-role.md: non-blocking wording suggestion
    • apps/storybook/stories/StatusMessageA11y.stories.tsx: clear
    • packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.renders.tsx: clear
    • packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.states.ts: clear
    • packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.test.tsx: clear
    • packages/core/src/Toast/Toast.doc.mjs: non-blocking doc wording
    • packages/core/src/Toast/Toast.standalone.test.tsx: clear
    • packages/core/src/Toast/Toast.tsx: non-blocking comment wording
    • packages/core/src/Toast/ToastViewport.tsx: clear
    • packages/core/src/hooks/useAnnounceRenderedText.adopters.test.tsx: clear

Automated review (maintainer link)

Comment on lines +400 to +401
// Only the viewport passes `announce`. The card never holds a live role, so
// a Toast rendered on its own announces nothing; its caller owns that.

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.

Non-blocking: this sentence carries three topics (the card's role, the lone Toast's silence, the caller's ownership). Suggested, one topic per sentence:

// Only the viewport passes `announce`. A Toast rendered on its own announces
// nothing. Its caller owns that announcement.

Comment thread packages/core/src/Toast/Toast.doc.mjs Resolved
@cixzhang cixzhang added the ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) label Nov 16, 2026
@duytbp

duytbp commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Thanks for picking this up! I checked out the head and ran the issue's repro: both the
type="error" and type="info" cards rendered on their own now have no role, aria-live or
aria-atomic, and their text stays visible. I also tried the case from our use: a persistent
Toast with a renderContent layout whose caller announces the message through useAnnounce
(assertive), then changes the body. The shared region reads "First", then "Second", and no
element of the card itself is a live region holding the text, so the message has a single owner.
Both cases fail on the merge base and pass here; the Toast suites pass too (163 tests with the
repro).

One small suggestion: callers (and their tests) that found the card with
closest('[role="status"]') or getByRole('alert') will stop matching, so a line in the
changeset saying the inline card no longer carries status/alert would help people spot it.

From the reporter's side this fully resolves #11942.

…o-live-role

# Conflicts:
#	packages/core/src/Toast/Toast.doc.mjs
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec b611671

@astracat-bot astracat-bot Bot 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.

Approved pending CI: CI has not run on this head yet.

A Toast rendered on its own now carries no live role, as the Toast contract requires (FR9); the new tests fail before the change and pass after it, and toasts shown through a viewport announce exactly as before. Before this can land, merge main again: it now conflicts in ToastViewport.tsx, where main wraps the viewport's <ToastSurface> in CallerTheme; keep that wrapper and drop the isLiveRegion={isLiveRegion} line.

Optional follow-ups, none blocking:

  • Toast.doc.mjs still says the card's "role, live-region attributes, and theme attributes stay component-owned" (line 144, and the same idea at lines 99 and 292), though the card now carries no role or live-region attributes.
  • The two removed status-message states were the only browser check that a toast card's text stays in the accessibility tree; the new test checks visibility in jsdom, so a small browser assertion for a lone card would keep that covered.
Claims and files checked

Review mode: full; reason: merge-touches-pr-files

  • Claim: a lone Toast no longer holds a live role. Verified: Toast.tsx:478-495 renders no role, aria-live or aria-atomic; the new test fails on the base and passes on the head.
  • Claim: a screen reader no longer reads it a second time when the caller announces it. Verified by routing: in Chromium's accessibility tree no live element holds the card's text; spoken output was not measured.
  • Claim: the card's text stays readable in browse mode. Verified: the text is exposed in the accessibility tree with no hidden ancestor; the test's visibility check passes.
  • Claim: only the viewport announces a toast, and a lone Toast's caller owns its announcement. Verified: the announcement gate at Toast.tsx:412-414; the viewport passes announce at ToastViewport.tsx:371 and :1018.
  • Claim (changeset and description): a Core patch release note in the fix category. Verified: the changeset check passes.
  • Claim: this fixes the reported issue. Verified: the issue's info and error cards lose all three attributes.
  • Claim: the card was a status region, or an alert region for errors. Verified on the base at Toast.tsx:486-488.
  • Claim: the earlier fix only made the viewport pass isLiveRegion={false}, the prop defaulted to true, and the public Toast never set it. Verified on the base at Toast.tsx:191 and :237 and ToastViewport.tsx:1023.
  • Claim: the prop is removed and the viewport was its only other user. Verified: the only other base reference was the rendered-text adopters test, updated here.
  • Claim: a component body or custom layout is read and announced only with the viewport's announce. Verified at Toast.tsx:414.
  • Claim: the Toast record says the card never holds a live role. Verified: Toast record FR9.
  • Claim: the status-announcements record lists the toast card under "no live element mounts holding its text". Verified: its FR2 and FR3 verification row.
  • Claim: no record changes. Verified.
  • Claim: the status-message inventory moves the toast card to its exclusions, citing FR9, and drops its two stories. Verified in StatusMessage.a11y.states.ts:248-254 and StatusMessageA11y.stories.tsx.
  • Claim: no public API change, since isLiveRegion was never in ToastProps. Verified: the API report generator finds no added, changed or removed entries for Core and the published themes.
  • Claim: red first, all three new cases fail before the change. Verified: 3 of 3 fail on the base.
  • Claim: 3 of 3 pass after. Verified.
  • Claim: the viewport, modal-host, overwrite, focus, FieldStatus, adopters, LayerProvider and ButtonGroup suites pass. Verified: 19 files and 344 tests pass on the head (the description's 13-file set is not named, so the count differs).
  • Claim: the Core type check is clean. Verified.
  • Claim: strict lint reports no errors on the changed files. Verified: no errors; three warnings, all present before this change.
  • Claim: the changesets are valid. Verified.
  • Claim: one defect, no tagalong, no hidden API, visual, default or interaction change, and no internal context. Verified.
  • File .changeset/toast-lone-card-no-live-role.md: clear.
  • File apps/storybook/stories/StatusMessageA11y.stories.tsx: clear.
  • File packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.renders.tsx: clear.
  • File packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.states.ts: clear; the exclusion reason matches FR9.
  • File packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.test.tsx: clear.
  • File packages/core/src/Toast/Toast.doc.mjs: note, stale wording at lines 99, 144 and 292.
  • File packages/core/src/Toast/Toast.standalone.test.tsx: note, visibility is checked in jsdom only.
  • File packages/core/src/Toast/Toast.tsx: note, the comment at lines 410-411 joins three topics in one sentence.
  • File packages/core/src/Toast/ToastViewport.tsx: note, it conflicts with main.
  • File packages/core/src/hooks/useAnnounceRenderedText.adopters.test.tsx: clear.

Automated review (maintainer link)

usage: {
description:
'Toast shows a brief, non-blocking notification to confirm an action or present temporary information; show one with `const showToast = useToast()`, which needs no provider or mounted ToastViewport: inside LayerProvider (or a ToastViewport) it uses that viewport, and otherwise the first toast mounts a fallback viewport on document.body with a development warning. Use it for scenarios where the user needs feedback but not a decision, such as saving, deleting, or changing a status.\n\nFor production use, prefer the `useToast()` hook; it handles positioning, stacking, auto-dismiss, and deduplication via `ToastViewport`. Toasts stay within viewport and safe-area gutters, wrap long message content, and enter, exit, or swipe-dismiss toward their configured top or bottom edge. The vertical swipe uses the same spatial model as placement motion: top Toasts leave upward and bottom Toasts leave downward. Swipe waits for dominant edge-directed intent before cancelling native touch movement and reports the existing manual dismissal reason. Pen is supported as direct-contact input; mouse drag is excluded to avoid conflicting with desktop text selection, where the visible close control remains available. Set `isAutoHide: false` explicitly when an action or message must remain available. The `Toast` component renders the visual toast element inline and is useful for previews, documentation, and static showcases where the viewport lifecycle is not needed. Host `data-*` attributes on `Toast` reach the toast element; its role, live-region attributes, and theme attributes stay component-owned.',
'Toast shows a brief, non-blocking notification to confirm an action or present temporary information; show one with `const showToast = useToast()`, which needs no provider or mounted ToastViewport: inside LayerProvider (or a ToastViewport) it uses that viewport, and otherwise the first toast mounts a fallback viewport on document.body with a development warning. Use it for scenarios where the user needs feedback but not a decision, such as saving, deleting, or changing a status.\n\nFor production use, prefer the `useToast()` hook; it handles positioning, stacking, auto-dismiss, and deduplication via `ToastViewport`. Only the viewport announces a toast: a `Toast` rendered on its own, as in a preview, is not a live region and announces nothing. Toasts stay within viewport and safe-area gutters, wrap long message content, and enter, exit, or swipe-dismiss toward their configured top or bottom edge. The vertical swipe uses the same spatial model as placement motion: top Toasts leave upward and bottom Toasts leave downward. Swipe waits for dominant edge-directed intent before cancelling native touch movement and reports the existing manual dismissal reason. Pen is supported as direct-contact input; mouse drag is excluded to avoid conflicting with desktop text selection, where the visible close control remains available. Set `isAutoHide: false` explicitly when an action or message must remain available. The `Toast` component renders the visual toast element inline and is useful for previews, documentation, and static showcases where the viewport lifecycle is not needed. Host `data-*` attributes on `Toast` reach the toast element; its role, live-region attributes, and theme attributes stay component-owned.',

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.

Non-blocking: this paragraph now says a lone Toast "is not a live region", but it still ends "its role, live-region attributes, and theme attributes stay component-owned". The compact usage text (line 292) says the same, and the renderContent description (line 99) says the card is not a live region only "inside a ToastViewport". Suggested ending: "Host data-* attributes on Toast reach the toast element; its theme attributes stay component-owned, and it carries no role or live-region attributes."

);
const text = screen.getByText('Changes saved');
expect(text.closest(LIVE)).toBeNull();
expect(text).toBeVisible();

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.

Non-blocking: toBeVisible() in jsdom does not read the accessibility tree. The status-announcements record's FR7 row names the toast card for an accessibility-tree check, and the two card states this pull request removes were its only browser coverage. A small browser assertion that a lone card's text is exposed, with no live ancestor, would keep that row covered.

…o-live-role

# Conflicts:
#	packages/core/src/Toast/ToastViewport.tsx
@cixzhang

Copy link
Copy Markdown
Contributor Author

/approve-spec 9c2d401

@astracat-bot astracat-bot Bot 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.

Approved. CI passes on this head.

A Toast rendered on its own now carries no live role, as the Toast contract requires; the new tests fail before the change and pass after it, and toasts shown through a viewport announce exactly as before.

Optional follow-ups, none blocking:

  • Toast.doc.mjs still says the card's "role, live-region attributes, and theme attributes stay component-owned" (line 144, and the same idea at lines 99 and 292), though the card now carries no role or live-region attributes.
  • The two removed status-message states were the only browser check that a toast card's text stays in the accessibility tree; the new test checks visibility in jsdom, so a small browser assertion for a lone card would keep that covered.
Claims and files checked

Review mode: same-head; reason: none

  • Claim (changeset): a lone Toast no longer holds a live role. Verified: Toast.tsx:478-495 renders no role, aria-live or aria-atomic; the new test fails on the base and passes on the head.
  • Claim (changeset): a screen reader does not read it a second time when the caller announces it. Verified by routing: in Chromium no live element holds the card's text; spoken output was not measured.
  • Claim (changeset and description): the card's text stays readable in browse mode. Verified: in Chromium the text has no hidden ancestor; the test's visibility check passes.
  • Claim (changeset and description): only the viewport announces a toast, and a lone Toast's caller owns its announcement. Verified: the announcement gate at Toast.tsx:412-414; the viewport passes announce at ToastViewport.tsx:404 and :1062.
  • Claim (changeset): a Core patch release note in the fix category that credits the reporter. Verified: the changeset check passes.
  • Claim: this fixes the reported issue. Verified: the issue's info and error cards lose all three attributes.
  • Claim: the card was a status region, or an alert region for errors. Verified in the base Toast.tsx.
  • Claim: the earlier fix only made the viewport pass isLiveRegion={false}, the prop defaulted to true, and the public Toast never set it. Verified in the base Toast.tsx and ToastViewport.tsx.
  • Claim: the prop is removed and the viewport was its only other user. Verified: the only other base reference was the rendered-text adopter test, updated here; no reference remains.
  • Claim: a component body or custom layout is read and announced only with the viewport's announce, so a lone Toast announces nothing. Verified at Toast.tsx:414 and by the custom-layout test.
  • Claim: the Toast record says the card never holds a live role. Verified: Toast record FR9.
  • Claim: the status-announcements record lists the toast card under "no live element mounts holding its text". Verified: its FR2 and FR3 verification row.
  • Claim: no record changes. Verified.
  • Claim: the status-message inventory moves the toast card to its exclusions, citing FR9, and drops its two stories. Verified in StatusMessage.a11y.states.ts:248-254 and StatusMessageA11y.stories.tsx.
  • Claim: the smallest restoration is Toast.tsx, ToastViewport.tsx and one doc sentence. Verified, with the tests, inventory, stories and changeset the description lists.
  • Claim: no public API change, since isLiveRegion was never in ToastProps. Verified: the API report generator finds no added, changed or removed entries for Core and the published themes.
  • Claim: red first, all three new cases fail before the change. Verified: 3 of 3 fail on the base.
  • Claim: 3 of 3 pass after. Verified.
  • Claim: the viewport, modal-host, overwrite, focus, FieldStatus, adopter, LayerProvider and ButtonGroup suites pass. Verified: 19 files and 344 tests pass on the head (the description's 13-file set is not named, so the count differs); CI's unit-test shards pass too.
  • Claim: the Core type check is clean. Verified; CI's typecheck passes.
  • Claim: strict lint reports no errors on the changed files. Verified; CI's lint passes.
  • Claim: the changesets are valid. Verified.
  • Claim: one defect, no tag-along, no hidden API, visual, default or interaction change, and no internal context. Verified: identical frames, no API rows, no internal references.
  • Claim: the spec stamp for this change is a defect repair. Verified: an engineering owner approved the spec for this exact head, and the spec-owner status passes.
  • File .changeset/toast-lone-card-no-live-role.md: clear.
  • File apps/storybook/stories/StatusMessageA11y.stories.tsx: clear.
  • File packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.renders.tsx: clear.
  • File packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.states.ts: clear; the exclusion reason matches FR9.
  • File packages/core/src/FieldStatus/__tests__/StatusMessage.a11y.test.tsx: clear.
  • File packages/core/src/Toast/Toast.doc.mjs: note, stale wording at lines 99, 144 and 292.
  • File packages/core/src/Toast/Toast.standalone.test.tsx: note, visibility is checked in jsdom only.
  • File packages/core/src/Toast/Toast.tsx: note, the comment at lines 410-411 joins three topics in one sentence.
  • File packages/core/src/Toast/ToastViewport.tsx: clear; it keeps main's CallerTheme wrapper.
  • File packages/core/src/hooks/useAnnounceRenderedText.adopters.test.tsx: clear.

Automated review (maintainer link)

@cixzhang
cixzhang marked this pull request as ready for review November 19, 2026 11:07
@cixzhang
cixzhang merged commit 7efbb4e into main Nov 19, 2026
156 checks passed
@github-actions
github-actions Bot deleted the fix/toast-lone-card-no-live-role branch November 20, 2026 06:05

This branch was successfully deployed

1 active deployment
Preview — 9c2d4019 Deployed Nov 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Toast: a Toast rendered on its own still holds a live role

2 participants