Repository navigation
fix(BottomSheet): keep toasts visible and clickable above an open sheet - #7781
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsToast (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression40 of 486 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 20 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
…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`.
User impact
With a
ToastViewport(fromLayerProvideroruseToast), a toast fired while aBottomSheetis open sits under the sheet, inert: a click on its Undo lands on the sheet, and on its transparent area dismisses aninfosheet. 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
Dialog, the sheet never supplies its modal<dialog>as an outlet, so the viewport stays below and outside it, inert.Top-layer order and modal inertness are spec-level, so WebKit should match; iOS is not verified.
Expected behavior and authority
spec:AST-003FR16 (Toast stays operable above the current native modal) and FR18 (each active native modal supplies an outlet).architecture:layer-runtimelists "a scrim BottomSheet or BottomSheetSwitcher" as a gap; this ships the BottomSheet half (IR5).Smallest restoration
BottomSheetcalls the privateuseModalOutlet(dialogRef, isOpen && hasScrim)after itsshowModal()effect, likeDialog, releasing when closing starts (the exiting dialog isinert).BottomSheetSwitcheris unchanged (still a listed gap).architecture:layer-runtimeupdated; storyCore/Toast/AppToastOverBottomSheetfor the browser proof.No public API, prop, default, or visual change.
Evidence
Chromium 149, 390×844, Storybook built with and without the fix;
elementFromPointat 5 toast points, then a click on Undo.Core/Toast/AppToastOverDialog, identical on both builds.ToastViewport.modalHost.test.tsx(3 fail without the fix; mutations under Testing) andBottomSheetToastOutlet.a11y.chromium.spec.ts(fails without the fix).Scope
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
docs/architecture/layer-runtime.md): none.Testing
pnpm exec vitest run --project ui packages/core: 453 files / 12690 tests pass.--project nodeat 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.BottomSheet.tsxline, againstToastViewport.modalHost.test.tsx: no registration fails 3; holding the outlet through the exit fails 2; registering a non-modal sheet fails 1; registering beforeshowModal()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).