Skip to content

fix(BottomSheet): a sheet whose close is suspended takes the scrim - #10776

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:bank/bottom-sheet-suspended-close-scrim
Nov 9, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:bank/bottom-sheet-suspended-close-scrim

Conversation

@vjeux

@vjeux vjeux commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

User impact

A stack of BottomSheets dims the page through its bottom sheet. An app can close the top sheet in a transition that suspends, as a navigation waiting on data does. The top sheet then stays open on screen. If the sheet beneath it closes in that time, the dim goes with it. The page behind the open modal sheet loses its dim while the close transition waits.

Problem and solution fit

  • Why does it happen? A sheet chooses its scrim when the stack reports a new view, from a ref of its open state. The sheet wrote that ref during render.
  • Why does that harm the sheet? A discarded render still writes the ref, so the suspended close leaves it false.
  • Why does that matter? When the sheet beneath closes, the open sheet reads itself as closing and does not take over the dim.

isOpen is a controlled prop; no callback in the sheet owns its change, so the ref is written at commit. Other refs in Core are still written during render; this change fixes only this one.

Expected behavior and authority

component:BottomSheet FR6: "Exactly one backdrop is visible for a stack — the bottom open sheet's — and a change of scrim owner lands with no transition, so the page dim is constant through a push, a pop, and a handoff."

Smallest restoration

In BottomSheet/BottomSheet.tsx, an insertion effect writes isOpenRef. A nested sheet's layout effects run before its host's, and their registry call can reach the host's onView. An insertion effect runs before every layout effect, as ComplexSelector's isDisabledRef and #10162's Chat refs do. No API changes.

Evidence

  • Reproduction before the change: the new case opens sheet A, then sheet B above it. It closes B in a transition that suspends for good, then closes A from code. On main, A drops its scrim and B does not take it (expected '0' to be '1').
  • Result after the change: B takes the scrim at once, and keeps it after A's exit ends.
  • Representative unchanged path: the same case without the transition passes on main and here.
  • Regression test or other mutation-sensitive proof: the new case fails on main.
  • The cause is React's render and commit order, so no browser engine changes the result. The stacking suite runs React's real scheduler in jsdom.

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.

Testing

  • Vitest: the new case in BottomSheetStacking.test.tsx fails on main and passes here. The stacking suite passed three times (87 tests). vitest related for BottomSheet.tsx: 206 files, 6,115 tests.
  • pnpm -F @astryxdesign/core typecheck: 0 errors. ESLint and Prettier on the changed files, the comment-provenance check, pnpm check:changesets and changeset coverage pass.

A sheet chose its scrim from a ref of its open state written during
render. A transition that closes the sheet and then suspends leaves the
sheet open on screen, with that ref false. If the sheet beneath it
closed meanwhile, the open sheet did not take over the dim, so the page
behind it lost its dim until the transition ended. The ref is now
written at commit, in an insertion effect, so every layout effect of
the commit reads it, a nested sheet's registry call included.

A new stacking case closes the top sheet in a transition that suspends
for good, then closes the sheet beneath it from code. It fails on main
and passes here; the same case without the transition passes on both.
@vercel

vercel Bot commented Nov 9, 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 Nov 9, 2026 12:12pm UTC

Request Review

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

astracat-bot Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 9, 2026, 12:20 PM UTC

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · b0cc450

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
BottomSheet 68.3 kB (+9 B) · 7.7 kB CSS (0) — ✗ · ✓ · —
BottomSheetSwitcher 17.9 kB (0) · 3.4 kB CSS (0) — ✗ · ✓ · —
PowerSearch 287.3 kB (+22 B) · 24.1 kB CSS (0) — — · — · —
22 more components
Component Size LoC Visual · A11y · RTL
DateTimeInput 208.7 kB (+13 B) · 18.7 kB CSS (0) — — · — · —
TimeInput 162.5 kB (+13 B) · 16.0 kB CSS (0) — — · — · —
DateInput 187.0 kB (+10 B) · 17.0 kB CSS (0) — — · — · —
lab/CommentThread 344.5 kB (+3 B) · 2.4 kB CSS (0) — — · — · —
lab/ChatEmojiPicker 106.1 kB (+2 B) · 773 B CSS (0) — — · — · —
Markdown 187.7 kB (+1 B) · 20.6 kB CSS (0) — — · — · —
MultiSelector 94.9 kB (+1 B) · 16.8 kB CSS (0) — — · — · —
lab/CommentComposer 152.1 kB (+1 B) · 1.9 kB CSS (0) — — · — · —
ContextMenu 108.4 kB (0) · 17.4 kB CSS (0) — — · — · —
DropdownMenu 97.3 kB (0) · 17.6 kB CSS (0) — — · — · —
MoreMenu 97.5 kB (0) · 17.6 kB CSS (0) — — · — · —
Pagination 110.0 kB (0) · 17.8 kB CSS (0) — — · — · —
Selector 99.9 kB (0) · 17.4 kB CSS (0) — — · — · —
Table 125.0 kB (0) · 18.3 kB CSS (0) — — · — · —
TableCell 109.7 kB (0) · 17.9 kB CSS (0) — — · — · —
Tokenizer 91.5 kB (0) · 18.8 kB CSS (0) — — · — · —
lab/ChatReactionBar 107.3 kB (0) · 1.1 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 278.2 kB (0) · 454 B CSS (0) — — · — · —
TableHeaderCell 109.2 kB (−1 B) · 17.7 kB CSS (0) — — · — · —
lab/TourStep 97.4 kB (−1 B) · 590 B CSS (0) — — · — · —
Popover 91.1 kB (−2 B) · 14.2 kB CSS (0) — — · — · —
lab/Comments 351.3 kB (−3 B) · 2.5 kB CSS (0) — — · — · —
Visual changes: 2 snapshots in 1 component

A change is a question for the reviewer, not a failure.

Component · story Before After Diff
BottomSheet · Text Only (neutral, dark) before frame after frame diff frame
BottomSheet · Text Only (neutral, light) before frame after frame diff frame

Package size: @astryxdesign/core 7.21 MB packed (+225 B); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 29 rows, core 36 rows, theme-butter 1 row, theme-y2k 1 row; run pnpm api:report.

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

@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. This is a draft from a fork, so CI runs once it is marked ready for review and a maintainer adds the ci:run label.

Writing isOpenRef at commit restores BottomSheet's single page dim when a stacked sheet's close waits in a suspended transition and the sheet beneath it closes; the new stacking case fails on main and passes here.

Two non-blocking notes: the inline suggestion rewords the comment above the insertion effect in active voice, and no test yet pins the insertion-effect timing over a layout effect for the nested-sheet case that comment describes.

[Automated review]

Comment on lines +507 to +510
// Written at commit: a render React discards, as a suspended transition
// does, must not change the scrim. The insertion effect runs before any
// layout effect, so a nested sheet's registry call in the same commit sees
// the new state too.

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.

Non-blocking: this comment opens with a passive fragment ("Written at commit:"). A wording in active voice, one topic per sentence:

Suggested change
// Written at commit: a render React discards, as a suspended transition
// does, must not change the scrim. The insertion effect runs before any
// layout effect, so a nested sheet's registry call in the same commit sees
// the new state too.
// A render that React discards, such as a suspended transition, must not
// change the scrim. So the ref changes at commit, before any layout
// effect. A nested sheet's registry call in that commit then reads the
// new value.

No test pins the second half yet: with useLayoutEffect here, every BottomSheet test still passes.

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Nov 9, 2026
@cixzhang

cixzhang commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

/approve-spec b0cc450

@vjeux
vjeux marked this pull request as ready for review November 9, 2026 13:00
@cixzhang
cixzhang merged commit 7f45363 into meta:main Nov 9, 2026
127 checks passed
@vjeux
vjeux deleted the bank/bottom-sheet-suspended-close-scrim branch November 9, 2026 13:30

This branch was successfully deployed

1 active deployment
Preview — b0cc450b Deployed Nov 9, 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) 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