Skip to content

fix(Toast): a toast dismissed while it opens leaves the stack - #14132

Merged
cixzhang merged 4 commits into
meta:mainfrom
vjeux:fix/toast-dismissed-while-opening
Dec 1, 2026
Merged

cixzhang merged 4 commits into
meta:mainfrom
vjeux:fix/toast-dismissed-while-opening

Conversation

@vjeux

@vjeux vjeux commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

User impact

Why: a toast dismissed while its row opens, in the task that mounts the row or as its entrance starts, can stay for good. A "working…" toast whose work settles at once gets there. Its empty, zero-height row stays, with the text inside.

What: a leaving row that the browser runs no collapse for now leaves at once, like a toast with no row on screen (#8050). A row whose collapse runs still waits for it.

How to check: in the ErrorPersists story, dismiss the toast as its row mounts. No [data-toast-id] row remains.

Problem and solution fit

  1. Why does it happen? removeToast marks the mounted row leaving and waits for its grid-template-rows transition to end. Before its entrance starts, the row is still at the collapsed value that leaving goes to. A dismissal as the entrance starts can cancel it with the row still closed. Either way no collapse starts, and transitionend never fires.
  2. Why does that harm the task? onExited never runs, so the row stays mounted at zero height.
  3. Why does that matter? The dismissed text stays in the page. The record's lingering-row gap names the rest: the row keeps the landmark (FR11), a maxVisible place (FR7), and an F6 stop (FR10).

Expected behavior and authority

component:Toast FR5: a dismissed card collapses and fades before it unmounts. The record lists a lingering zero-height row only for a viewport moving between outlets.

Smallest restoration

One layout effect in ToastRow syncs the exit with the browser's CSS transitions. Once the row is leaving, if getAnimations() shows no grid-template-rows transition on it, it calls onExited at once. Without getAnimations (jsdom) the row keeps waiting, so existing tests are unchanged. The record's FR4–FR5 verification row names the new spec.

Evidence

  • Before: with main's ToastViewport.tsx, the spec fails. Chromium fails its two on-mount cases, and WebKit all six: the row stays.
  • After: every case passes in both engines.
  • Unchanged path: "collapses a dismissed Toast before unmounting it", and the new "keeps a dismissed Toast until its collapse ends when the browser runs one".
  • Regression tests: this browser spec, and the jsdom case "removes a dismissed Toast at once when the browser runs no collapse for it".

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.

#8121 delays a leaving row's collapse until a touch retract ends. Whichever lands second keys this check on isCollapsing, not isExiting.

Testing

Every run is at 8f34741, which merges main 22f1866 into this branch, after pnpm install --frozen-lockfile and pnpm build. "With main's file" means ToastViewport.tsx from 22f1866, with Storybook rebuilt. Five steps overlapped memory pressure from other work on the machine. Each passed, apart from the three failures named below, which fail the same way in a quiet run.

  • ToastDismissWhileOpening.interaction.browser.spec.ts, --repeat-each=5:
    • Chromium: 30 of 30 pass. With main's file, 10 of 30 fail: both on-mount cases, 5 of 5 each (test).
    • WebKit, through webkit-container.mjs: 30 of 30 pass. With main's file, 28 of 30 fail, each with its row still there. The case that dismisses as the entrance starts passes once in each motion setting (test).
  • pnpm exec vitest run --project ui packages/core/src/Toast packages/core/src/Layer/toastHost.test.tsx packages/core/src/Layer/toastHost.lateRegistration.test.tsx packages/core/src/Layer/LayerProvider.test.tsx: 13 files, 200 tests pass. With main's file, ToastViewport.test.tsx fails 1 of 114, the new jsdom case (test).
  • pnpm test:ui --maxWorkers=16: 1,179 files and 28,165 tests pass; none fail or skip (test).
  • pnpm test:node, with Chromium on PATH: 30,609 tests pass, 3 are expected fails, 106 skip and 1 is a todo; 3 fail (test).
    • The 3 are swizzle-proof slices 2, 3 and 4. Each fails one Lab table hook at its render step: useTableRowExpansionDataSource, useTableServerPagination and useTableTreeDataSource.
    • At a merge commit the proof compares with its first parent, so here it proves every target. On main 22f1866 with every target, the same three fail with the same errors (test).
    • With main as the base, as a pull request's merge commit runs, all eight slices pass, with this change's one affected target (test).
  • ASTRYX_STRICT_LINT=1 ESLint with --max-warnings=0 on the three changed files: 0 errors and 1 warning. It is the unused viewport at ToastViewport.test.tsx:4038, which main has at its line 4002. This change adds none.
  • pnpm -F @astryxdesign/core typecheck, Prettier, pnpm check:changesets, pnpm check:repo, pnpm specs:for --diff origin/main and pnpm review:pre (0 findings) each exit 0 (test).
  • pnpm check:knowledge exits 0. Its two advisories are in another record on main, which this change does not touch (test).

Writing rubric results

  • R1 narration: the changed verification cell states what the spec checks, in the present tense.
  • R2 research: none.
  • R3 evidence: the changed cell names a test file and what it checks, not a pull request, issue or commit.
  • R4 rejected alternatives: none.
  • R5 change references: none.
  • R6 open questions: none.
  • R7 project status: none in the changed cell.

Drafted with an AI coding agent; the tests were run as described.

A row dismissed before its entrance starts, or as it starts, finds no
collapse to run: the browser starts no transition, so no transitionend
removes the row. Once a row is leaving, a layout effect now asks
getAnimations() for its grid-template-rows transition and, with none,
calls onExited at once.
@vercel

vercel Bot commented Dec 1, 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 Dec 1, 2026 11:41am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Dec 1, 2026, 11:45 AM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Dec 1, 2026
@cixzhang cixzhang added ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) ci:run-a11y Run the accessibility suite on this PR; write access, next push (AST-030 FR12) labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 1460dad

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
Toast · Storybook 110.7 kB (0) · 11.6 kB CSS (0) 1,883 (+19) ✓ · ✓ · ✓

Package size: @astryxdesign/core 8.14 MB packed (+397 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

@cixzhang

cixzhang commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 50ccbf4

vjeux added 2 commits December 1, 2026 00:08
FR5's verification row now names
ToastDismissWhileOpening.interaction.browser.spec.ts. It dismisses a
toast as its row mounts, as its entrance starts and one frame after,
with and without reduced motion.

@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. The pull request is a draft, so marking it ready for review starts the run; the ci:run label is already applied.

No blocking findings: the new layout effect ends a row's exit at once only when the browser starts no collapse for it, which restores the Toast record's rule that a dismissed card unmounts, while an open or partway-open row still waits for its collapse. The Chromium and WebKit before-and-after results come from your test plan, so the CI run of the new jsdom cases and browser spec is what confirms them at this head.

Claims and files checked

Review mode: full; reason: no-earlier-review

  • Claim: a toast dismissed while it opens now leaves the stack. Verified from the code for every moment of the entrance (ToastViewport.tsx:361-376 when no transition starts, :399-401 for the reverse transition); the browser spec drives all three moments.
  • Claim: dismissed before or as its entrance started, the row found no collapse and stayed as an empty zero-height row with its text inside. Reported; consistent with the base code, where the row unmounts only on its own transitionend and the leaving style equals the entrance's starting style.
  • Claim: a row whose collapse the browser runs still waits for it to end. Verified (ToastViewport.tsx:373, :399-401; jsdom case "keeps a dismissed Toast until its collapse ends when the browser runs one").
  • Claim: a leaving row with no collapse now leaves at once, like a toast with no row on screen. Verified (ToastViewport.tsx:373-375, compared with :784-800).
  • Claim: without getAnimations (jsdom) the row keeps waiting, so existing tests are unchanged. Verified (ToastViewport.tsx:363; the test setup adds no getAnimations, no test that renders a toast stubs it, and no existing test is edited).
  • Claim: the lingering row keeps the landmark, holds a maxVisible place and gives F6 a hidden target. Verified on the base code (ToastViewport.tsx:1075, :891, :1036-1039).
  • Claim: the Toast record requires the unmount and lists a lingering row only for a viewport moving between outlets. Verified against the current record.
  • Claim: one layout effect in the row syncs the exit with the browser's CSS transitions. Verified (ToastViewport.tsx:358-376).
  • Claim: no new public API, visual representation, default or interaction model, and no internal context. Verified from the diff.
  • Claim: the ErrorPersists story reproduces the case. Verified that the story and its button exist and that the spec drives them; the result is reported.
  • Claim: the before-and-after browser runs, the unit and full test suites, lint, typecheck and repository checks. Reported; CI has not run them at this head.
  • Claim: the one lint warning in the test file already exists on main. Verified (the same line, shifted by the 36 added lines).
  • Claim: coordination with the open swipe pull request that delays a row's collapse. Reported; that pull request is an open draft and is not on main.
  • File: packages/core/src/Toast/ToastViewport.tsx: clear.
  • File: packages/core/src/Toast/ToastViewport.test.tsx: clear.
  • File: packages/core/src/Toast/__tests__/ToastDismissWhileOpening.interaction.browser.spec.ts: clear.
  • File: .changeset/toast-dismissed-before-entrance-leaves.md: clear.

Automated review (maintainer link)

@github-actions github-actions Bot added the needs:spec-owner-review Current knowledge records await owner approval label Dec 1, 2026
@cixzhang

cixzhang commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 8f34741

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Dec 1, 2026

@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; marking the draft ready for review starts it, and the ci:run label is already applied.

There are no blocking findings: the new layout effect ends a row's exit at once only when the browser starts no collapse for it, which restores the Toast record's rule that a dismissed card unmounts, while an open or partly open row still collapses first. A local Chromium check with the row's own styles showed both outcomes, and the WebKit and test-suite results come from your test plan, so CI's run confirms them at this head.

Claims and files checked

Review mode: full; reason: spec-record

  • Claim (title, changeset): a toast dismissed while it opens now leaves the stack. Verified: the new effect ends the exit when no collapse runs (ToastViewport.tsx:361-376) and the existing transitionend path ends it when one runs (:399-401); a local Chromium check with the row's styles showed one of the two outcomes at every entrance moment.
  • Claim (changeset, description): dismissed before or as its entrance started, the row found no collapse and stayed as an empty zero-height row with its text inside. Reported; consistent with the base code and with the local Chromium check of the on-mount case.
  • Claim (changeset, description): a row whose collapse the browser runs still waits for it to end. Verified: the effect calls onExited only when no grid-template-rows transition is listed (:373); in the local Chromium check an open row's collapse was listed at once and ran about 180 ms; the jsdom case "keeps a dismissed Toast until its collapse ends when the browser runs one" covers the branch.
  • Claim: a leaving row with no collapse now leaves at once, like a toast with no row on screen. Verified (:373-375, compared with :784-799).
  • Claim: without getAnimations (jsdom) the row keeps waiting, so existing tests are unchanged. Verified (:363; the shared test setup defines no getAnimations, only the two new cases stub it, and no existing test is edited).
  • Claim: the lingering row keeps the landmark, a maxVisible place and an F6 stop. Verified on the base code (:1075, :891, :1036-1039).
  • Claim: the Toast record requires the unmount and lists a lingering row only for a viewport moving between outlets. Verified against the current record.
  • Claim: one layout effect in the row syncs the exit with the browser's CSS transitions. Verified (:358-376).
  • Claim: the record's FR4–FR5 verification row names the new spec. Verified (Toast.spec.md:267).
  • Claim: the ErrorPersists story reproduces the case. Verified that the story and its button exist and that the new spec drives them; the result is reported.
  • Claim: no new public API, visual representation, default or interaction model, and no internal context. Verified from the diff.
  • Claim: a progress toast whose work settles at once reaches the bug. Reported.
  • Claim: the before-and-after browser runs in Chromium and WebKit, the unit and full suites, lint, typecheck and repository checks. Reported; CI has not run them at this head.
  • Claim: the one lint warning in the test file already exists on main. Verified (the same line, shifted by the added lines).
  • Claim: coordination with the open swipe pull request that delays a row's collapse. Reported; that pull request is an open draft outside this change.
  • Claim: writing rubric results for the changed record cell. Verified (present tense, names a test file, no change references).
  • File: .changeset/toast-dismissed-before-entrance-leaves.md: clear.
  • File: docs/specs/components/Toast/Toast.spec.md: clear.
  • File: packages/core/src/Toast/ToastViewport.tsx: clear.
  • File: packages/core/src/Toast/ToastViewport.test.tsx: clear.
  • File: packages/core/src/Toast/__tests__/ToastDismissWhileOpening.interaction.browser.spec.ts: clear.

Automated review (maintainer link)

@vjeux
vjeux marked this pull request as ready for review December 1, 2026 09:32

@cixzhang cixzhang 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 at 8f34741 (CodeBunny APPROVE at this head after push and body, CI green incl. pr-a11y, Specs ✓).

@vjeux
vjeux marked this pull request as draft December 1, 2026 10:42
@vjeux
vjeux marked this pull request as ready for review December 1, 2026 10:42

@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: the full CI run at this head, with build, test and docsite-test, is queued and has not finished, and nothing merges until it passes.

There are no blocking findings. The new layout effect ends a row's exit at once only when the browser starts no collapse for it, which restores the Toast record's rule that a dismissed card unmounts, while an open or partly open row still collapses first. Typecheck, lint and the CLI smoke test pass in CI at this head; the Chromium and WebKit results come from your test plan, and CI's full run will confirm the new tests.

Claims and files checked

Review mode: carry-forward; reason: none

  • Claim (title, changeset): a toast dismissed while it opens now leaves the stack. Verified from reading the code: with no grid-template-rows transition listed the new effect ends the exit (ToastViewport.tsx:361-376), and a listed one ends it through transitionend (:399-401); the new jsdom case and browser spec contain the opening moments and wait on CI. A collapse that an outlet move cancels later still lingers, which is the record's separate known gap for every dismissed toast.
  • Claim (changeset, description): dismissed before or as its entrance started, the row found no collapse and stayed as an empty zero-height row with its text inside. Reported; consistent with the base code, where the leaving style equals the entrance's starting style (:183-188, :204-207) and only transitionend unmounts a row.
  • Claim (changeset, description): a row whose collapse the browser runs still waits for it to end. Verified: the effect calls onExited only when no collapse is listed (:373), and the jsdom case "keeps a dismissed Toast until its collapse ends when the browser runs one" asserts the row stays until the collapse ends.
  • Claim: a leaving row with no collapse now leaves at once, like a toast with no row on screen. Verified (:373-375, compared with :784-799).
  • Claim: without getAnimations (jsdom) the row keeps waiting, so existing tests are unchanged. Verified: the guard at :363; the shared test setup defines no getAnimations; of the 15 core test files that mention ToastViewport, useToast or ToastProvider, only ToastViewport.test.tsx mentions it, in the two new cases; no existing test is edited.
  • Claim: the lingering row keeps the landmark, a maxVisible place and an F6 stop. Verified on the base code (:1075, :891, :1036-1039).
  • Claim: the Toast record requires the unmount and lists a lingering row only for a viewport moving between outlets. Verified against the current record (FR5 and its known gaps).
  • Claim: one layout effect in the row syncs the exit with the browser's CSS transitions. Verified (:358-376).
  • Claim: the record's FR4–FR5 verification row names the new spec. Verified (Toast.spec.md:267).
  • Claim: the ErrorPersists story reproduces the case. Verified that the story and its "Trigger error" button exist and that the new spec drives them; the result is reported.
  • Claim: no new public API, visual representation, default or interaction model, and no internal context. Verified from the diff.
  • Claim: a progress toast whose work settles at once reaches the bug. Reported.
  • Claim: the before-and-after browser runs in Chromium and WebKit, the unit and full suites, lint, typecheck and repository checks. Reported; CI's typecheck and lint pass at this head, and the test suites wait on its full run.
  • Claim: the one lint warning in the test file already exists on main. Verified (the same line, shifted by the 36 added lines).
  • Claim: coordination with the open swipe pull request that delays a row's collapse. Reported; outside this change.
  • Claim: writing rubric results for the changed record cell. Verified (present tense, names a test file, no change references).
  • File: .changeset/toast-dismissed-before-entrance-leaves.md: clear.
  • File: docs/specs/components/Toast/Toast.spec.md: clear.
  • File: packages/core/src/Toast/ToastViewport.tsx: clear.
  • File: packages/core/src/Toast/ToastViewport.test.tsx: clear.
  • File: packages/core/src/Toast/__tests__/ToastDismissWhileOpening.interaction.browser.spec.ts: clear.

Automated review (maintainer link)

@cixzhang

cixzhang commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

/approve-spec 1460dad

@cixzhang cixzhang 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.

Re-approved at 1460dad (main merge only; CodeBunny APPROVE at this head after the push, CI green incl. pr-a11y, Specs ✓).

@cixzhang
cixzhang merged commit cf34d2e into meta:main Dec 1, 2026
147 of 150 checks passed
@vjeux
vjeux deleted the fix/toast-dismissed-while-opening branch December 1, 2026 16:13

This branch was successfully deployed

1 active deployment
Preview — 1460dad0 Deployed Dec 1, 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 A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) 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.

2 participants