Repository navigation
fix(Toast): a toast raised while the window is in the background starts with its timer paused - #9615
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Toast · Storybook | 59.4 kB (+10 B) · 10.1 kB CSS (0) | 1,518 (+3) | ✓ · ✓ · ✓ |
| LayerProvider | 62.7 kB (+8 B) · 10.5 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 6.00 MB packed (+165 B); no new dependencies.
Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
The fix itself looks right: a toast raised while the window has no focus now starts held, the new test fails on main and passes here, and a real-browser run shows the toast surviving the background and hiding after focus returns. One change is needed before this lands: the record's at-a-glance row at line 53 of docs/specs/components/Toast/Toast.spec.md still says "Nineteen implementation gaps", but this pull request removes one of them, so it should read "Eighteen". Optionally, add a changeset sentence that jsdom reports no document focus until an element is focused, so consumer tests that assert auto-hide now need to focus an element or mock document.hasFocus, as this pull request's own test files do.
[Automated review]
| // A toast raised while the window is already blurred gets no blur event, | ||
| // so it starts held, and the window's next focus resumes it. |
There was a problem hiding this comment.
Non-blocking: this sentence carries three topics. A shorter form with one fact per sentence: A window that is already blurred fires no blur event. Start the toast held. The next window focus resumes it.
There was a problem hiding this comment.
This looks ready: a toast raised while the window has no focus now starts held, the new test fails on main and passes here, and the record's gap count now reads "Eighteen". Two optional touches: shorten the new comment in Toast.tsx to its one quirk ("A window that is already blurred fires no blur event."), and consider a changeset sentence that consumer jsdom tests asserting auto-hide now need to focus an element or mock document.hasFocus. The repository's spec gate still waits for an engineering owner's /approve-spec.
[Automated review]
|
/approve-spec 8878b7f |
|
/approve-spec 002098a |
There was a problem hiding this comment.
This looks ready: a toast raised while the window has no focus now starts held, the new test fails on main and passes here, and the record edit closes FR2's gap with an engineering owner's approval at this head.
Before it can merge, docs/specs/components/Toast/Toast.spec.md conflicts with main in the verification map, because main changed the FR12 row to "modal and scrimless drawers" and this branch re-pads the whole table: keep that wording when resolving, and the new head needs /approve-spec again. Optionally, shorten the new comment in Toast.tsx to its one quirk ("A window that is already blurred fires no blur event.") and add a changeset sentence that consumer jsdom tests asserting auto-hide now need to focus an element or mock document.hasFocus.
[Automated review]
|
/approve-spec 2250641 |
There was a problem hiding this comment.
This looks ready to merge: a toast raised while the window has no focus now starts with its auto-hide timer held, the new test fails on main and passes here, and the record edit closes FR2's implementation gap with an engineering owner's approval at this head.
Two optional touches:
- Shorten the new comment in
Toast.tsxto its one quirk: "A window that is already blurred fires no blur event." - Consider a changeset sentence that consumer jsdom tests asserting auto-hide now need a focused element or a
document.hasFocusmock, since jsdom reports no document focus until an element is focused.
[Automated review]
Fixes #8969
User impact
This affects someone in another window or tab when an app raises an auto-hiding toast. Today the toast's timer starts at once, so it can disappear before they come back and they never see it. After this change, a toast raised while the window is in the background starts paused, and its timer runs once the window has focus again.
The other part of #8969, tracking each pause source separately (pointer, focus, gesture, window), is already on
main. This closes the remaining gap that Toast FR2 names.Authority
component:ToastFR2: "the timer pauses while … the window is blurred". Its implementation gap reads "a toast raised while the window is already blurred starts its timer". FR2 and AR3 require the timer to pause while the user can't read the toast (WCAG 2.2.1 Timing Adjustable).Change
Toast.tsx: when the window-pause listeners attach anddocument.hasFocus()is false, the toast takes thewindowhold at once. The window's nextfocusevent releases it, as it does after a blur.Toast.spec.md: FR2's gap sentence becomes "A toast raised while the window is already blurred starts with its timer held". The matching Current-state impact bullet is removed, and the FR2 verification row names the new test.ToastViewport.test.tsxandToastViewport.modalHost.test.tsxnow treat the test page as a focused window. jsdom reports no window focus until an element is focused, so without this, toasts in those files would start held.[fix].Verification
Unit, red first: "starts its auto-hide timer held until the window regains focus" fails on
mainand passes here. The Toast suites pass (110 tests), as do the other suites that raise toasts. Lint, type check andcheck-knowledgeare clean.Real Chromium 154 (2 s toast; "background" means another tab is in front, so
document.hasFocus()is false):main