Repository navigation
fix(Toast): a Toast rendered on its own holds no live role - #11960
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec 281f2e9 |
PR Analysis Report🔎 Preview ·
|
| 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
There was a problem hiding this comment.
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
Toastnever 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 loneToastannounces nothing: verified inToast.tsxand 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).
- A lone card was a live region (status or alert, with live and atomic attributes): verified in the base
- Files
.changeset/toast-lone-card-no-live-role.md: non-blocking wording suggestionapps/storybook/stories/StatusMessageA11y.stories.tsx: clearpackages/core/src/FieldStatus/__tests__/StatusMessage.a11y.renders.tsx: clearpackages/core/src/FieldStatus/__tests__/StatusMessage.a11y.states.ts: clearpackages/core/src/FieldStatus/__tests__/StatusMessage.a11y.test.tsx: clearpackages/core/src/Toast/Toast.doc.mjs: non-blocking doc wordingpackages/core/src/Toast/Toast.standalone.test.tsx: clearpackages/core/src/Toast/Toast.tsx: non-blocking comment wordingpackages/core/src/Toast/ToastViewport.tsx: clearpackages/core/src/hooks/useAnnounceRenderedText.adopters.test.tsx: clear
| // 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. |
There was a problem hiding this comment.
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.|
Thanks for picking this up! I checked out the head and ran the issue's repro: both the One small suggestion: callers (and their tests) that found the card with From the reporter's side this fully resolves #11942. |
…o-live-role # Conflicts: # packages/core/src/Toast/Toast.doc.mjs
|
/approve-spec b611671 |
There was a problem hiding this comment.
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.mjsstill 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
Toastno longer holds a live role. Verified:Toast.tsx:478-495renders norole,aria-liveoraria-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 atToast.tsx:412-414; the viewport passesannounceatToastViewport.tsx:371and: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 publicToastnever set it. Verified on the base atToast.tsx:191and:237andToastViewport.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 atToast.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-254andStatusMessageA11y.stories.tsx. - Claim: no public API change, since
isLiveRegionwas never inToastProps. 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 withmain. - File
packages/core/src/hooks/useAnnounceRenderedText.adopters.test.tsx: clear.
| 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.', |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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
|
/approve-spec 9c2d401 |
There was a problem hiding this comment.
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.mjsstill 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
Toastno longer holds a live role. Verified:Toast.tsx:478-495renders norole,aria-liveoraria-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 atToast.tsx:412-414; the viewport passesannounceatToastViewport.tsx:404and: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 publicToastnever set it. Verified in the baseToast.tsxandToastViewport.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 loneToastannounces nothing. Verified atToast.tsx:414and 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-254andStatusMessageA11y.stories.tsx. - Claim: the smallest restoration is
Toast.tsx,ToastViewport.tsxand one doc sentence. Verified, with the tests, inventory, stories and changeset the description lists. - Claim: no public API change, since
isLiveRegionwas never inToastProps. 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 keepsmain'sCallerThemewrapper. - File
packages/core/src/hooks/useAnnounceRenderedText.adopters.test.tsx: clear.
Fixes #11942
User impact
A screen-reader user can hear a
Toasttwice when an app renders it on its own (outside aToastViewport) and also announces the message, for example throughuseAnnounceso it is read over an open modal. The card was a live region (role="status", orrole="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
ToastViewportshows (the viewport passedisLiveRegion={false}). ButisLiveRegionwas an internal prop that defaulted totrue, and the publicToastnever set it, so a loneToastkeptrole,aria-liveandaria-atomicon its card.isLiveRegionprop is removed; the viewport was its only other user, and it always passedfalse. The card reads and announces a component body or a custom layout only when the viewport hands itannounce, so aToastrendered on its own announces nothing. Its caller owns that announcement.Expected behavior and authority
component:ToastFR9: "The card never holds a live role." The viewport is each shown toast's one announcement owner.spec:AST-086FR2 and FR3 list "toast card" under "no live element mounts holding its text".Smallest restoration
Toast.tsx(no live attributes; the rendered-text announcement is gated on the viewport'sannounce),ToastViewport.tsx(the removed prop), and one sentence inToast.doc.mjs: only the viewport announces a toast, and aToastrendered on its own announces nothing.isLiveRegionwas never part ofToastProps.@astryxdesign/corepatch,[fix].Evidence
Toast.standalone.test.tsxhas three cases. Before the change, all 3 fail:Scope
Components: Toast
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.