Skip to content

fix(BottomSheet): keep toasts visible and clickable above an open sheet - #7781

Merged
imdreamrunner merged 1 commit into
meta:mainfrom
vjeux:bottom-sheet-toast-outlet
Oct 23, 2026
Merged

imdreamrunner merged 1 commit into
meta:mainfrom
vjeux:bottom-sheet-toast-outlet

Conversation

@vjeux

@vjeux vjeux commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

User impact

With a ToastViewport (from LayerProvider or useToast), a toast fired while a BottomSheet is open sits under the sheet, inert: a click on its Undo lands on the sheet, and on its transparent area dismisses an info sheet. Reproduced in Chromium at phone width; narrow desktop windows and Android Chrome are real configurations. With the fix the toast paints above the sheet and takes the click, as above a Dialog.

Problem and solution fit

  • Why it happens: unlike Dialog, the sheet never supplies its modal <dialog> as an outlet, so the viewport stays below and outside it, inert.
  • Why it hurts: the action's feedback is covered and its Undo unreachable.
  • Why it matters: apps can't work around it; the outlet registry is private.

Top-layer order and modal inertness are spec-level, so WebKit should match; iOS is not verified.

Expected behavior and authority

spec:AST-003 FR16 (Toast stays operable above the current native modal) and FR18 (each active native modal supplies an outlet). architecture:layer-runtime lists "a scrim BottomSheet or BottomSheetSwitcher" as a gap; this ships the BottomSheet half (IR5).

Smallest restoration

  • A standalone BottomSheet calls the private useModalOutlet(dialogRef, isOpen && hasScrim) after its showModal() effect, like Dialog, releasing when closing starts (the exiting dialog is inert).
  • Non-modal sheets don't register; BottomSheetSwitcher is unchanged (still a listed gap).
  • architecture:layer-runtime updated; story Core/Toast/AppToastOverBottomSheet for the browser proof.

No public API, prop, default, or visual change.

Evidence

Chromium 149, 390×844, Storybook built with and without the fix; elementFromPoint at 5 toast points, then a click on Undo.

AppToastOverBottomSheet without with
Sheet alone 0/5 hits; click dismisses the sheet 5/5; Undo runs
Sheet over a Dialog 0/5; click dismisses the sheet 5/5; Undo runs
  • Representative unchanged path: Core/Toast/AppToastOverDialog, identical on both builds.
  • Regression tests: 4 in ToastViewport.modalHost.test.tsx (3 fail without the fix; mutations under Testing) and BottomSheetToastOutlet.a11y.chromium.spec.ts (fails without the fix).

Scope

  • 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.

Known limits: an exiting sheet keeps the toast inert until its dialog closes. Draft #7648 reorders sheets by closing and re-showing dialogs, which releases their outlets.

Writing rubric results

  • R1 narration (docs/architecture/layer-runtime.md): none.
  • R2 research: none.
  • R3 evidence naming a change: none.
  • R4 rejected alternatives: none.
  • R5 pull request or issue references: none.
  • R6 open questions: none touched.

Testing

  • pnpm exec vitest run --project ui packages/core: 453 files / 12690 tests pass. --project node at 32 workers: 10732 pass; 16 CLI theme/build/search tests hit the 30 s timeout under that load, and their 13 files pass at --maxWorkers=4 (428 tests).
  • pnpm -F @astryxdesign/core typecheck, tsc -p packages/core/tsconfig.build.json --noEmit (compiles the new spec), ESLint on changed files, pnpm check:repo: pass.
  • Mutations of the new BottomSheet.tsx line, against ToastViewport.modalHost.test.tsx: no registration fails 3; holding the outlet through the exit fails 2; registering a non-modal sheet fails 1; registering before showModal() fails 1.
  • pnpm exec playwright test packages/core/src/BottomSheet/__tests__/BottomSheetToastOutlet.a11y.chromium.spec.ts --project chromium: 2/2 pass; against a Storybook built without the fix, 2/2 fail at the hit test (expected "Undo", received null).

A BottomSheet opens its <dialog> with showModal() but did not supply it as a
modal outlet, so a top-layer ToastViewport stayed in the root, or in a Dialog
under the sheet. The sheet painted over it and made it inert: a click on a
toast's action landed on the sheet, and on its transparent area dismissed it.

A standalone sheet now calls useModalOutlet while it is open as a modal, after
the effect that runs showModal(), as Dialog does. It releases the outlet as
soon as it starts closing, because the closing dialog stays modal but inert and
hidden through its exit animation. Sheets without a scrim are not modal and do
not register. BottomSheetSwitcher is unchanged.
@vercel

vercel Bot commented Oct 21, 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 Oct 21, 2026 4:31am UTC

Request Review

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

astracat-bot Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 21, 2026, 5:06 AM UTC

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

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

Toast (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1361 -
Complexity N/A Very High (139) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

40 of 486 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 754,077
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,188
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
RichTextEditor Markdown parity: side by side probe dark 94,866
RichTextEditor Markdown parity: side by side probe light 89,762
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232
ProgressBar With Target Mark probe dark 7,895
ProgressBar With Target Mark probe light 7,895
Markdown Default neutral dark 7,573
Markdown Default neutral light 7,566

and 20 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | 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.

The fix is in good shape: a standalone modal BottomSheet now supplies its dialog as the toast outlet, so a toast fired from an open sheet stays visible above it and its Undo works, as AST-003 FR16 and FR18 require. Browser checks reproduce the old behaviour (a press on Undo dismissed the sheet) and confirm the fix in Chromium and WebKit, for a sheet on its own and over a Dialog. The remaining step is an owner of architecture:layer-runtime approving the record update. Optionally, renaming BottomSheetToastOutlet.a11y.chromium.spec.ts to .a11y.browser.spec.ts would let CI run it in WebKit too, where it already passes unchanged.

[Automated review]

// Copyright (c) Meta Platforms, Inc. and affiliates.

/**
* @file BottomSheetToastOutlet.a11y.chromium.spec.ts

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.

This scenario also passes unchanged under the repository's WebKit Playwright project (2/2 against this head's Storybook). The WebKit project only picks up .a11y.browser.spec.ts files, so naming this BottomSheetToastOutlet.a11y.browser.spec.ts would let CI check the modal outlet in both engines; holdMotionStill uses only standard Playwright calls.

cixzhang pushed a commit that referenced this pull request Oct 22, 2026
…oses them (#7851)

## User impact

A person who dismisses a file picker (Escape, or Cancel in the chooser) from an upload field inside a `Dialog` or `BottomSheet` loses the whole surface: it closes and takes any unsaved form state with it, although they only backed out of the picker. Inside a `BottomSheetSwitcher` step, the whole flow closes.

## Problem and solution fit

- Why does it close? A file input fires a `cancel` event at itself when its picker closes without a selection, and that event bubbles (HTML Standard, file upload state). It reaches the `<dialog>`.
- Why is that a dismissal? Each component treats every `cancel` reaching its `<dialog>` as the platform close request and dismisses, whatever its target. A switcher step renders no dialog, so the switcher's receives it.
- Why does it matter? Backing out of a picker is not a request to close the layer, and treating it as one discards work.

The fix ignores a `cancel` whose target is not the component's own `<dialog>`. A close request is fired at the dialog itself and does not bubble, so no real dismissal is lost.

## Expected behavior and authority

`family:overlay-dismissal` (current) names the dismissal commands: Escape or a platform close request (the close-request row and FR3). `component:Dialog` routes its dismissal to that family. A `cancel` bubbling up from a control inside the layer is neither.

## Smallest restoration

One early return at the top of the three `handleCancel`s (`Dialog`, `BottomSheet`, `BottomSheetSwitcher`), before `preventDefault()`: `if (event.target !== event.currentTarget) return;`, leaving the input's event alone. No API, default or visual change; a patch changeset.

## Evidence

- Reproduction before the change: in Chromium 149, a click on a file input inside a modal `<dialog>` (headless dismisses the picker at once) delivers `cancel` to the dialog with the input as `target`. On `main` the four new tests fail: each component dismisses for the picker's `cancel`.
- Result after the change: both stay open, and the picker's event is not default-prevented.
- Representative unchanged path: each component's own `cancel` still closes it (new tests); the existing Escape, `required`, IME and nesting tests pass.
- Regression test: `Dialog.test.tsx` › "a cancel from inside the dialog" (two cases), `BottomSheet.test.tsx` › "stays open when a file picker inside it is dismissed…" and `BottomSheetSwitcher.test.tsx` › "keeps the flow open when a file picker inside a step is dismissed…".

## Scope

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

## Testing

- Sibling: #7781 also edits `BottomSheet.tsx`, in another region; the two merge cleanly and pass together (below).
- `pnpm exec vitest run packages/core/src/Dialog packages/core/src/BottomSheet packages/core/src/Layer`: 23 files, 584 tests passed, including the 4 new ones (red on `main`; the switcher case also red on the first head).
- With #7781 merged in, adding `packages/core/src/Toast`: 26 files, 660 passed.
- `pnpm -F @astryxdesign/core typecheck`, eslint and prettier on the changed files, and the pre-commit `check:repo` steps: clean.
- Real browser (Chromium 149, Playwright): a click on `<input type="file">` inside a modal `<dialog>` gives one `cancel` at the dialog, with the input as target and `bubbles: true`.
@vjeux
vjeux marked this pull request as draft October 23, 2026 22:57
@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Oct 23, 2026
@vjeux
vjeux marked this pull request as ready for review October 23, 2026 22:58
@imdreamrunner
imdreamrunner merged commit 7cb897b into meta:main Oct 23, 2026
60 checks passed
@vjeux
vjeux deleted the bottom-sheet-toast-outlet branch October 23, 2026 23:23

This branch was successfully deployed

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

Labels

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