Skip to content

fix(BottomSheet): keep snap points and the reentry in state - #10873

Merged
cixzhang merged 10 commits into
meta:mainfrom
vjeux:fix/bottom-sheet-snap-points-in-state
Nov 13, 2026
Merged

cixzhang merged 10 commits into
meta:mainfrom
vjeux:fix/bottom-sheet-snap-points-in-state

Conversation

@vjeux

@vjeux vjeux commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Render-time ref writes fixed in core/BottomSheet/BottomSheetPanel.tsx: snapPointsRef, read by the stop resolver, and two writes of reactivatedEntranceRef, read by the motion layout effect. Folded in, read in a callback: core/BottomSheet/useSheetGestures.ts snapHeightsRef. Red-first: yes, "rests at the committed stop when React discards a render that moves it" fails on main.

User impact

People who drag a BottomSheet with snap points in an app that renders with transitions. BottomSheetPanel copied its snap points into a ref written during render, and the sheet's gestures copied the stop resolver the same way. A render React discards, as a suspended transition does, left its values there. A released drag could then rest at a stop the sheet never committed.

The panel also kept whether an entrance brings back a retained sheet in a ref written during render.

Problem and solution fit

A write during render runs for every render, including the ones React throws away. The drag resolves its stops on release, after the render that wrote them.

The snap points are now state, kept with their key and adjusted during render when the key changes. So the resolver's identity still changes only when the stops do. The gestures' resolver now comes from useCommittedRef, which writes at commit, before the re-anchor's layout effect reads it. The entrance flag is state, adjusted as the panel's state changes, and the motion effect reads it. The three motion callbacks come from useCommittedRef too, instead of a layout effect's copy.

Expected behavior and authority

  • React's useRef contract: do not write ref.current during rendering, except to initialize it.
  • React's "Storing information from previous renders": adjust state while rendering.
  • architecture:react-component-runtime INV3 and INV17: a latest-value ref goes through useCommittedRef, and render writes no ref. INV4: no rendered value comes from a ref mutation.

Smallest restoration

Six refs in BottomSheetPanel.tsx, three of them the motion callbacks, and one in useSheetGestures.ts. No API, visual or default changes.

Evidence

  • Reproduction before the change: the new test fails on main 723a112, with the whole test file run. The sheet rests at 784px instead of 448px.
  • Result after the change, at 19e445b: it passes.
  • Representative unchanged path: the existing snap point and re-anchor tests still pass.
  • Regression test or other mutation-sensitive proof: the test also fails with only the panel's change, since the gestures' resolver still carries the discarded stops.

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

All runs below are at this PR's head, 19e445b.

The new test opens a tall sheet with a stop at half the window. It renders a stop at a quarter of the window in a transition that suspends for good. React keeps the committed tree and never commits that render. It then drags the handle to the committed stop and releases it.

Ref Now Test
snapPointsRef (BottomSheetPanel.tsx) State, kept with its key Red-first: a released drag rests at the committed stop.
snapHeightsRef (useSheetGestures.ts) useCommittedRef, written before the re-anchor reads it The same test; it stays red without this change.
reactivatedEntranceRef (BottomSheetPanel.tsx, two writes) State, adjusted as the panel's state changes No new test. A discarded render's state adjustment is discarded with it, so the motion layout effect never reads its flag. The existing reactivation test covers the flag.
The three motion callback refs useCommittedRef, no longer copied by a layout effect No new test. The layout effect already wrote them at commit, so no discarded render reached them.
  • pnpm exec vitest run packages/core/src/BottomSheet --project ui: 14 files, 617 tests pass. On main's panel and gestures, with the whole file run, the new test fails and the other 159 pass.

  • pnpm exec vitest run --project ui: 1,010 files, 25,130 tests pass.

  • @astryxdesign/core typecheck: 0 errors. ESLint and Prettier on the changed files: clean.

  • History: main merged at 146df1e on Nov 11, with no conflicts, so CI runs on a current base. The change's own diff is unchanged.

  • History: the merge of main 2aa31a3 on Nov 12 has one conflict, in BottomSheetPanel.tsx. Main's snap-points ref, from fix(Table): call the latest onSortChange from useTableSortableState #11349, gives way to this PR's keyed state, and its lint disable goes with it. The next commit moves the gestures' resolver onto useCommittedRef.

  • Browser specs at this head, on a Storybook built at it: BottomSheet interaction specs, Chromium 22 passed (1 skipped) and WebKit (CI-profile container) 12 passed (11 skipped). BottomSheet a11y specs, Chromium 92 passed; their .browser specs in the WebKit container, 55 passed (1 skipped).

  • History: the merge of main 06b7e61 on Nov 12 has no conflicts. It brings main's changes to three files that BottomSheetPanel.tsx reaches through its imports: motion/animator.ts, useMobileKeyboard.ts and keyboardHeight.ts. The change's own diff is unchanged.

  • History: a changeset-only commit narrows its second sentence to a discarded snapPoints change, the case this PR fixes and tests.

  • History: the merge of main badd698 on Nov 12 has no conflicts. It brings main's change to motion/animator.ts, which BottomSheetPanel.tsx reaches through its imports. The change's own diff is unchanged.

  • At 1764d83, in a first run of these gates, four BottomSheetPinchZoom cases failed: the story's dialog did not appear within 5 s. One ChatVirtualizer case in lab failed too. All five passed in reruns there. With a delay injected into each test, both failures reproduce the same way on main badd698. The story's sheet opens in a median of 330 ms at that head and 327 ms on main, over 10 runs each. At this head, every gate passed on its first run.

  • History: the merge of main a4595ef on Nov 12 has no conflicts. BottomSheetPanel.tsx and useSheetGestures.ts reach one of main's changes, utils/clickGuard.ts. The test file also reaches BottomSheet.tsx from fix(BottomSheet): sync its return target at commit #10918, and the react import both sides added appears once.

  • History: the merge of main 723a112 on Nov 12 has no conflicts. BottomSheetPanel.tsx reaches four of main's changes since a4595ef: utils/themeProps.ts, which it imports, utils/sharedResizeObserver.ts, theme/generateThemeRules.ts and theme/tokenReferences.ts. The change's own diff is unchanged.

BottomSheetPanel copied its snap points, and whether an entrance
brings back a retained sheet, into refs written during render. The
sheet's gestures copied the stop resolver the same way. A render React
discards, as a suspended transition does, left its values there, so a
released drag could rest at a stop the sheet never committed.

The snap points are now state, kept with their key. The entrance is
state adjusted as the panel's state changes. The gestures sync the
resolver in a layout effect declared before the re-anchor that reads
it.
@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 13, 2026 1:57am 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 13, 2026, 2:05 AM UTC

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 19e445b

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
BottomSheet 70.0 kB (+9 B) · 7.7 kB CSS (0) — ✗ · ✓ · —
BottomSheetSwitcher 18.7 kB (0) · 3.4 kB CSS (0) — ✗ · ✓ · —
DateTimeInput 218.0 kB (+33 B) · 19.1 kB CSS (0) — — · — · —
21 more components
Component Size LoC Visual · A11y · RTL
TimeInput 168.9 kB (+27 B) · 16.4 kB CSS (0) — — · — · —
DateInput 195.5 kB (+25 B) · 17.4 kB CSS (0) — — · — · —
PowerSearch 302.2 kB (+17 B) · 24.7 kB CSS (0) — — · — · —
Table 131.7 kB (+2 B) · 18.7 kB CSS (0) — — · — · —
lab/CommentThread 359.2 kB (+2 B) · 2.4 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 285.4 kB (+2 B) · 454 B CSS (0) — — · — · —
Popover 96.3 kB (+1 B) · 14.6 kB CSS (0) — — · — · —
TableHeaderCell 114.6 kB (+1 B) · 18.0 kB CSS (0) — — · — · —
DropdownMenu 103.0 kB (0) · 17.9 kB CSS (0) — — · — · —
Markdown 194.7 kB (0) · 21.1 kB CSS (0) — — · — · —
Pagination 116.2 kB (0) · 18.2 kB CSS (0) — — · — · —
Selector 106.0 kB (0) · 17.9 kB CSS (0) — — · — · —
TableCell 115.1 kB (0) · 18.3 kB CSS (0) — — · — · —
lab/ChatReactionBar 112.8 kB (0) · 1.1 kB CSS (0) — — · — · —
lab/CommentComposer 157.4 kB (0) · 1.9 kB CSS (0) — — · — · —
ContextMenu 113.8 kB (−1 B) · 17.8 kB CSS (0) — — · — · —
MoreMenu 103.3 kB (−1 B) · 17.9 kB CSS (0) — — · — · —
MultiSelector 100.2 kB (−1 B) · 17.2 kB CSS (0) — — · — · —
Tokenizer 102.6 kB (−1 B) · 19.5 kB CSS (0) — — · — · —
lab/ChatEmojiPicker 111.6 kB (−1 B) · 773 B CSS (0) — — · — · —
lab/Comments 366.2 kB (−1 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.47 MB packed (+78 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

@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; it runs once the pull request is marked ready for review and a maintainer adds the ci:run label.

Keeping the snap points in state and syncing the drag's stop resolver at commit means a render React discards no longer moves the stop a released drag rests at; the new test fails without either half of the change and passes with both.

Two optional comment rewrites are suggested inline (non-blocking).

[Automated review]

@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 f640d2b

@vjeux
vjeux marked this pull request as ready for review November 11, 2026 16:30
@vjeux
vjeux marked this pull request as draft November 11, 2026 16:43
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 1c7a9df

@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; it runs once the pull request is marked ready for review (the ci:run label is already on it).

Keeping the snap points in state and syncing the drag's stop resolver at commit means a render React discards no longer moves the stop a released drag rests at. The new test fails on the base and with either half of the change alone, and passes on this head after the merge from main.

The two earlier inline comment-style suggestions still apply and are non-blocking.

Automated review (maintainer link)

The gestures copied the snap-height resolver into a ref in a layout
effect declared before the re-anchor effect. The shared internal hook
writes it at commit before any layout effect, so the gestures call it.
The detent callback lists the ref in its dependencies.
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec ab6da7a

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

Changes requested: keeping the snap points and the entrance flag in state, and reading the stop resolver through useCommittedRef, is the right fix, but three things need to change first.

  • Newly live check: the layout effect at BottomSheetPanel.tsx:815-819, which this pull request edits, still copies onMotionStart, onMotionComplete and onScrimFadeDuration into refs in a per-component Effect, which the runtime architecture's INV3 now routes through useCommittedRef, so replace those three refs with useCommittedRef(...) and delete the Effect, as this pull request already does for snapHeightsRef.
  • The description's opening line says snapPointsRef and the two reactivatedEntranceRef writes are read during render, but on the current base snapPointsRef is read only inside the resolver at call time and reactivatedEntranceRef only in the motion layout effect, so please reword it.
  • The Testing table says the entrance flag's reader runs only when the motion changes, but the motion layout effect also re-runs when isCrossFade or playedDragExit changes and when a Suspense boundary shows the sheet again (see the comment at BottomSheetPanel.tsx:1018-1021), so please reword that row or add a test for the discarded-render path.

Two small non-blocking suggestions are inline, and the two earlier comment-style suggestions still apply.

Claims and files checked
  • Changeset: snap points and the entrance flag live in state, the resolver syncs at commit, and a discarded render no longer moves where a release rests. Verified in code (BottomSheetPanel.tsx:797-813, :840-862; useSheetGestures.ts:716); a test run has not yet confirmed the behaviour.
  • The panel's snap-points ref and both entrance-ref writes are read during render. False (base BottomSheetPanel.tsx:839, :1017).
  • The gestures' resolver ref is read in a callback. Verified (useSheetGestures.ts:894).
  • Main copied the snap points and the resolver into refs during render, and a discarded render left its values there. Verified (base BottomSheetPanel.tsx:828-829, useSheetGestures.ts:717-718).
  • Main kept the entrance flag in a ref written during render. Verified (base BottomSheetPanel.tsx:798, :800).
  • The snap points are keyed state, so the resolver's identity changes only with the stops. Verified (BottomSheetPanel.tsx:841-862).
  • The resolver comes from useCommittedRef, written before the re-anchor's layout effect reads it. Verified (insertion Effect in useCommittedRef.ts; useSheetGestures.ts:1016-1022).
  • The entrance flag is state that the motion effect reads. Verified (BottomSheetPanel.tsx:797-813, :1033, :1097).
  • The cited runtime rules: no render-time ref writes, latest-value refs through useCommittedRef, no rendered value from a ref mutation. Verified against the current runtime architecture record.
  • An earlier Lab pull request made the same kind of change. Verified (#10780, merged).
  • Three refs change in the panel and one in the gestures, with no API, visual or default change. Verified (diff; package exports unchanged).
  • The entrance flag's reader runs only when the motion changes, so it needs no new test. False (BottomSheetPanel.tsx:1018-1021, :1097).
  • The new test fails on main (784px instead of 448px), passes at this head, and also fails with only the panel's change. Unverified: needs a test run; the base code path reads the discarded stops.
  • The BottomSheet suite passes (14 files, 616 tests), and the existing snap-point tests pass, including a re-anchor under a resting sheet. Unverified: needs a test run.
  • Typecheck, ESLint and Prettier are clean. Unverified: needs a run.
  • History: the first merge of main had no conflicts, the second had one in BottomSheetPanel.tsx resolved to the keyed state with its lint disable dropped, and the next commit moves the resolver onto useCommittedRef. Verified (merge history; no lint disable remains at the memo).
  • Scope: one defect restored, no hidden API, visual, default or interaction change, no internal context. Verified.
  • .changeset/bottom-sheet-snap-points-in-state.md: clear.
  • packages/core/src/BottomSheet/BottomSheet.test.tsx: clear (read; red-first not yet confirmed by a run).
  • packages/core/src/BottomSheet/BottomSheetPanel.tsx: the Effect finding above; non-blocking notes inline.
  • packages/core/src/BottomSheet/useSheetGestures.ts: clear; one non-blocking comment note inline.

Automated review (maintainer link)

A layout effect copied onMotionStart, onMotionComplete and
onScrimFadeDuration into refs. They now come from useCommittedRef, as
INV3 asks, listed in the deps of the effects that read them. The scrim
fade's cleanup reads the callback through a function its effect
declares, so the host's current callback hears the fade end.

The entrance flag's update drops a branch that cannot run, and three
comments keep only their reasons.
@vjeux

vjeux commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Answers to the review of ab6da7a, at 9985aa8: the three motion callbacks now come from useCommittedRef, and their layout effect is gone. The opening line names where each ref is read, and the entrance row no longer says when the motion effect runs. The four smaller suggestions are applied.

@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 9985aa8

@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; it runs once the pull request is marked ready for review (the ci:run label is already on it).

Keeping the snap points and the entrance flag in state, and reading the stop resolver and the three motion callbacks through useCommittedRef, keeps a released drag on the committed stop after a discarded render, and every point from the last review is addressed. CI's run of the BottomSheet suite, typecheck and lint is the remaining check.

Claims and files checked
  • Changeset: the sheet keeps its snap points and its reactivated entrance in state and syncs the drag's stop resolver at commit, so a discarded render no longer changes where a released drag rests. Verified in code (BottomSheetPanel.tsx:797-809, :829-851; useSheetGestures.ts:715).
  • The panel's snap-points ref, read by the stop resolver, and two writes of the entrance ref, read by the motion layout effect, were written during render. Verified (base BottomSheetPanel.tsx:828-829, :839, :798, :800, :1017).
  • The gestures' resolver ref was written during render and read in a callback. Verified (base useSheetGestures.ts:717-718; head :893).
  • A render React discards left its values in those refs, so a released drag could rest at a stop the sheet never committed. Verified in code: React re-attempts the suspended render after each commit, and each attempt rewrote both refs on the base.
  • The snap points are keyed state, so the resolver's identity changes only with the stops. Verified (BottomSheetPanel.tsx:829-851).
  • The resolver comes from useCommittedRef, written at commit before the re-anchor's layout effect reads it. Verified (insertion Effect in useCommittedRef.ts; useSheetGestures.ts:715, :1015-1021).
  • The entrance flag is state adjusted as the panel's state changes, and the motion effect reads it. Verified (BottomSheetPanel.tsx:797-809, :1023, :1091).
  • The three motion callbacks come from useCommittedRef instead of a layout effect's copy. Verified (BottomSheetPanel.tsx:788-790; the copy effect is gone).
  • The cited rules: no ref writes during render except initialization, state adjusted while rendering for previous-render information, latest-value refs through the shared hook, and no rendered value from a ref mutation. Verified against the current runtime architecture record.
  • Six refs change in the panel, three of them the motion callbacks, and one in the gestures, with no API, visual or default change. Verified (diff; the BottomSheet exports are unchanged).
  • The new test fails on main (784px instead of 448px), passes at this head, and also fails with only the panel's change. Consistent with the code on both sides; CI runs the test.
  • The BottomSheet suite passes (14 files, 616 tests), including the existing snap-point and re-anchor tests, and typecheck, ESLint and Prettier are clean. Left to CI, which runs them before merge.
  • No new test for the entrance flag: a discarded render's state adjustment is discarded with it, and the existing reactivation test covers the flag. Verified (BottomSheetPanel.test.tsx:530).
  • No new test for the motion callbacks: the old layout effect already wrote them at commit. Verified (base BottomSheetPanel.tsx:803-808).
  • History: the first merge of main had no conflicts; the second had one in BottomSheetPanel.tsx, resolved to the keyed state with its lint disable dropped; the next commit moved the resolver onto useCommittedRef. Verified (merge history; no lint disable left in the panel).
  • Scope: one defect restored, no hidden API, visual, default or interaction change, no internal context. Verified.
  • .changeset/bottom-sheet-snap-points-in-state.md: clear.
  • packages/core/src/BottomSheet/BottomSheet.test.tsx: clear.
  • packages/core/src/BottomSheet/BottomSheetPanel.tsx: clear.
  • packages/core/src/BottomSheet/useSheetGestures.ts: clear.

Automated review (maintainer link)

@vjeux
vjeux marked this pull request as ready for review November 12, 2026 13:12
@vjeux
vjeux marked this pull request as draft November 12, 2026 14:06
@vjeux
vjeux marked this pull request as draft November 12, 2026 15:57
github-actions Bot added a commit that referenced this pull request Nov 12, 2026
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 1764d83

@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; it runs once the pull request is marked ready for review (the ci:run label is already present).

The only change since the last review is a merge of main that leaves this pull request's own diff unchanged; the animator option it brings in is opt-in and BottomSheet does not use it. One optional follow-up remains: BaseTypeahead.tsx (lines 823-825) still cites BottomSheetPanel's layout-effect onMotionStartRef as its precedent, which this change removes.

Claims and files checked
  • Changeset: the sheet keeps its snap points and its reactivated entrance in state and syncs the drag's stop resolver at commit. Verified (BottomSheetPanel.tsx:797-809, :829-851; useSheetGestures.ts:715).
  • Changeset: a discarded render that changes snapPoints no longer changes where a released drag rests. Verified: the stops change only at commit, and the other render-time values the release reads do not take snapPoints (useSheetGestures.ts:631-632, :707-712).
  • The panel's snap-points ref, read by the stop resolver, and two writes of the entrance ref, read by the motion layout effect, were written during render; so was the gestures' resolver ref, read in a callback. Verified (base BottomSheetPanel.tsx:828-829, :798, :800, :1017; base useSheetGestures.ts:717-718).
  • A discarded render left its values in those refs, so a released drag could rest at a stop the sheet never committed. Verified in code for snap points: the retried transition render rewrote both refs on the base.
  • The snap points are keyed state, so the resolver's identity changes only with the stops. Verified (BottomSheetPanel.tsx:829-851).
  • The resolver comes from useCommittedRef, written at commit before the re-anchor's layout effect reads it. Verified (useCommittedRef.ts:35-38; useSheetGestures.ts:715, :1015-1021).
  • The entrance flag is state adjusted as the panel's state changes, and the motion effect reads it. Verified (BottomSheetPanel.tsx:797-809, :1023, :1091).
  • The three motion callbacks come from useCommittedRef instead of a layout effect's copy. Verified (BottomSheetPanel.tsx:788-790; the copy effect is gone).
  • The cited rules: no ref writes during render except initialization, state adjusted while rendering for previous-render information, latest-value refs through the shared hook, and no rendered value from a ref mutation. Verified against the current runtime architecture record.
  • Six refs change in the panel, three of them the motion callbacks, and one in the gestures, with no API, visual or default change. Verified from the diff and the package source.
  • The new test fails on main (784px instead of 448px), passes after the change, and also fails with only the panel's change. Consistent with the code on both sides; not run here, and CI has not run on this head.
  • The BottomSheet suite (14 files, 616 tests) and the whole UI project pass, and typecheck, ESLint and Prettier are clean. Not run here; CI runs them before merge.
  • No new test for the entrance flag or the motion callbacks: a discarded render's state update is discarded with it, the existing reactivation test covers the flag, and the old copy was already commit-time. Verified (BottomSheetPanel.test.tsx:530; base BottomSheetPanel.tsx:803-808).
  • History: the merges of main had no conflicts except one in BottomSheetPanel.tsx, resolved to the keyed state; the next commit moved the resolver onto useCommittedRef; a changeset-only commit narrows the second sentence; the latest merge of main brings an animator change the panel imports and leaves the change's own diff unchanged. Verified (commit history; the patch is byte-identical to the one reviewed before that merge, and the merged animator option is opt-in and unused by BottomSheet).
  • Browser interaction and accessibility specs pass in Chromium and WebKit, and the first run's PinchZoom and ChatVirtualizer failures pass on rerun. Not reproduced here.
  • Scope: one defect restored, no hidden API, visual, default or interaction change, no internal context. Verified.
  • .changeset/bottom-sheet-snap-points-in-state.md: clear.
  • packages/core/src/BottomSheet/BottomSheet.test.tsx: clear.
  • packages/core/src/BottomSheet/BottomSheetPanel.tsx: clear.
  • packages/core/src/BottomSheet/useSheetGestures.ts: clear.

Automated review (maintainer link)

@vjeux
vjeux marked this pull request as ready for review November 12, 2026 17:16
@vjeux
vjeux marked this pull request as draft November 12, 2026 17:51
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 49a8b33

@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; it runs once the pull request is marked ready for review (the ci:run label is already present).

The only change since the last review is a merge of main: the source changes are unchanged, and the test now shares the react import that main added. The new test fails on main (the sheet rests at 784px instead of 448px), fails with either half of the fix alone, and passes on this head. One optional follow-up remains: BaseTypeahead.tsx (lines 823-825) still cites BottomSheetPanel's layout-effect onMotionStartRef as its precedent, which this change removes.

Claims and files checked
  • Changeset: the sheet keeps its snap points and its reactivated entrance in state and syncs the drag's stop resolver at commit. Verified (BottomSheetPanel.tsx:797-809, :829-851; useSheetGestures.ts:715).
  • Changeset: a discarded render that changes snapPoints no longer changes where a released drag rests. Verified: the new test fails on the base and passes here, and the other render-time values the release reads do not take snapPoints (useSheetGestures.ts:631-632, :707-712).
  • The panel's snap-points ref, read by the stop resolver, and two writes of the entrance ref, read by the motion layout effect, were written during render; so was the gestures' resolver ref, read in a callback. Verified (base BottomSheetPanel.tsx:798, :800, :828-829, :1017; base useSheetGestures.ts:717-718).
  • A discarded render left its values in those refs, so a released drag could rest at a stop the sheet never committed. Verified for snap points by the red-first run.
  • The snap points are keyed state adjusted during render, so the resolver's identity changes only with the stops. Verified (BottomSheetPanel.tsx:829-851).
  • The resolver comes from useCommittedRef, written at commit before the re-anchor's layout effect reads it. Verified (useCommittedRef.ts:35-38; useSheetGestures.ts:715, :1015-1021).
  • The entrance flag is state adjusted as the panel's state changes, and the motion effect reads it. Verified (BottomSheetPanel.tsx:797-809, :1023, :1091).
  • The three motion callbacks come from useCommittedRef instead of a layout effect's copy. Verified (BottomSheetPanel.tsx:788-790; the copy effect is gone).
  • The cited rules: no ref writes during render except initialization, state adjusted while rendering for previous-render information, latest-value refs through the shared hook, and no rendered value from a ref mutation. Verified against the current runtime architecture record.
  • Six refs change in the panel, three of them the motion callbacks, and one in the gestures, with no API, visual or default change. Verified from the diff; the built API surfaces of Core and the themes compare with no changed row.
  • The new test fails on main (784px instead of 448px) with the whole file run, and passes after the change. Verified: run here on both trees, with the other 159 tests in the file passing on the base.
  • The existing snap-point and re-anchor tests still pass. Verified (the BottomSheet suite passes here).
  • The new test also fails with only the panel's change. Verified (run here; it also fails with only the gestures' change).
  • No new test for the entrance flag or the motion callbacks: a discarded render's state update is discarded with it, the existing reactivation test covers the flag, and the old copy was already commit-time. Verified (BottomSheetPanel.test.tsx:530; base BottomSheetPanel.tsx:803-808).
  • The BottomSheet suite (14 files, 617 tests) passes. Verified (run here).
  • The whole UI project (1,007 files) passes. Not run here; CI runs it before merge.
  • Core typecheck has 0 errors, and ESLint and Prettier are clean on the changed files. Verified (run here).
  • History: the earlier merges of main, one conflict resolved to the keyed state, the move of the resolver onto the shared hook, and the changeset-only narrowing. Consistent with the commit history: main's snap-points ref and its lint disable are gone at this head, the resolver moves in the commit after that merge, and the narrowing commit touches only the changeset.
  • History: the latest merge of main has no conflicts; the panel and gestures reach the click guard change, and the test shares the react import both sides added. Verified for the panel, which reaches the click guard through the keyboard height module; the guard's new option is opt-in and unused by the sheet, and the import appears once.
  • Browser interaction and accessibility specs pass in Chromium and WebKit, and the first-run failures at the previous head passed on rerun. Not reproduced here.
  • Scope: one defect restored, no hidden API, visual, default or interaction change, no internal context. Verified.
  • .changeset/bottom-sheet-snap-points-in-state.md: clear.
  • packages/core/src/BottomSheet/BottomSheet.test.tsx: clear.
  • packages/core/src/BottomSheet/BottomSheetPanel.tsx: clear.
  • packages/core/src/BottomSheet/useSheetGestures.ts: clear.

Automated review (maintainer link)

@vjeux
vjeux marked this pull request as ready for review November 12, 2026 20:15
github-actions Bot added a commit that referenced this pull request Nov 12, 2026
@vjeux
vjeux marked this pull request as draft November 12, 2026 20:51
@vjeux
vjeux marked this pull request as ready for review November 12, 2026 20:59
github-actions Bot added a commit that referenced this pull request Nov 12, 2026
@vjeux
vjeux marked this pull request as draft November 12, 2026 21:44
@cixzhang

Copy link
Copy Markdown
Contributor

/approve-spec 19e445b

@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; it runs once the pull request is marked ready for review (the ci:run label is already present).

The only change since the last review is a merge of main with no conflicts, and the pull request's own diff is unchanged. The new test still fails on main (the sheet rests at 784px instead of 448px), fails with either half of the fix alone, and passes on this head with the whole BottomSheet suite. One optional follow-up remains: Typeahead/BaseTypeahead.tsx (lines 823-825) still cites BottomSheetPanel's layout-effect onMotionStartRef as its precedent, which this change removes.

Claims and files checked
  • Changeset: the sheet keeps its snap points and its reactivated entrance in state and syncs the drag's stop resolver at commit. Verified (BottomSheetPanel.tsx:797-809, :829-851; useSheetGestures.ts:715).
  • Changeset: a discarded render that changes snapPoints no longer changes where a released drag rests. Verified: the new test fails on the base and passes here, and the other render-time values the release reads do not take snapPoints (useSheetGestures.ts:631-632, :707-712).
  • The panel's snap-points ref, read by the stop resolver, and two writes of the entrance ref, read by the motion layout effect, were written during render; so was the gestures' resolver ref, read in a callback. Verified (base BottomSheetPanel.tsx:798, :800, :828-829, :1017; base useSheetGestures.ts:717-718).
  • A discarded render left its values in those refs, so a released drag could rest at a stop the sheet never committed. Verified for snap points by the red-first run.
  • The snap points are keyed state adjusted during render, so the resolver's identity changes only with the stops. Verified (BottomSheetPanel.tsx:829-851).
  • The resolver comes from useCommittedRef, written at commit before the re-anchor's layout effect reads it. Verified (useCommittedRef.ts:35-38; useSheetGestures.ts:715, :1015-1021).
  • The entrance flag is state adjusted as the panel's state changes, and the motion effect reads it. Verified (BottomSheetPanel.tsx:797-809, :1023, :1091).
  • The three motion callbacks come from useCommittedRef instead of a layout effect's copy. Verified (BottomSheetPanel.tsx:788-790; the copy effect is gone).
  • The cited rules: no ref writes during render except initialization, state adjusted while rendering for previous-render information, latest-value refs through the shared hook, and no rendered value from a ref mutation. Verified against the current runtime architecture record.
  • Six refs change in the panel, three of them the motion callbacks, and one in the gestures, with no API, visual or default change. Verified from the diff; the built API surfaces of Core and the themes compare with no changed row.
  • The new test fails on main (784px instead of 448px) with the whole file run, and passes after the change. Verified: run here on both trees, with the other 159 tests in the file passing on the base.
  • The existing snap-point and re-anchor tests still pass. Verified (the BottomSheet suite passes here).
  • The new test also fails with only the panel's change. Verified (run here; it also fails with only the gestures' change).
  • No new test for the entrance flag or the motion callbacks: a discarded render's state update is discarded with it, the existing reactivation test covers the flag, and the old copy was already commit-time. Verified (BottomSheetPanel.test.tsx:530; base BottomSheetPanel.tsx:803-808).
  • The BottomSheet suite (14 files, 617 tests) passes. Verified (run here).
  • The whole UI project passes. Not run here; CI runs it before merge.
  • Core typecheck has 0 errors, and ESLint and Prettier are clean on the changed files. Verified (run here).
  • History: the earlier merges of main, one conflict resolved to the keyed state, the move of the resolver onto the shared hook, and the changeset-only narrowing. Consistent with the commit history: main's snap-points ref and its lint disable are gone at this head, the resolver moves in the commit after that merge, and the narrowing commit touches only the changeset.
  • History: the latest merge of main has no conflicts; the panel reaches four of main's changes (theme props, the shared resize observer, the theme rule generator and token references), and the change's own diff is unchanged. Verified: those four are the changed files the panel reaches through runtime imports, each gains an export or a padding-parsing fix the sheet's drag does not use, and the patch is byte-identical to the last reviewed one.
  • Browser interaction and accessibility specs pass in Chromium and WebKit, and earlier first-run failures passed on rerun. Not reproduced here.
  • Scope: one defect restored, no hidden API, visual, default or interaction change, no internal context. Verified.
  • .changeset/bottom-sheet-snap-points-in-state.md: clear.
  • packages/core/src/BottomSheet/BottomSheet.test.tsx: clear.
  • packages/core/src/BottomSheet/BottomSheetPanel.tsx: clear.
  • packages/core/src/BottomSheet/useSheetGestures.ts: clear.

Automated review (maintainer link)

@vjeux
vjeux marked this pull request as ready for review November 13, 2026 02:13
github-actions Bot added a commit that referenced this pull request Nov 13, 2026
@cixzhang
cixzhang merged commit 5072eb6 into meta:main Nov 13, 2026
130 checks passed
@vjeux
vjeux deleted the fix/bottom-sheet-snap-points-in-state branch November 13, 2026 03:09

This branch was successfully deployed

1 active deployment
Preview — 19e445bd Deployed Nov 13, 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