Skip to content

fix(core): BottomSheet reads the scroll edge of the box under the finger - #7168

Merged
imdreamrunner merged 1 commit into
meta:mainfrom
vjeux:sheet-nested-scroll
Oct 8, 2026
Merged

imdreamrunner merged 1 commit into
meta:mainfrom
vjeux:sheet-nested-scroll

Conversation

@vjeux

@vjeux vjeux commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

User impact

Anyone using a BottomSheet on a touch screen whose content scrolls in a box of its own inside the sheet body: a pinned header and footer around a scrolling middle, a grid or list that owns its overflow. Once that box is scrolled, every pull down over it drags the sheet (and, past the dismiss line, closes it) instead of scrolling the box back up. The box cannot be scrolled back by hand at all; the only way up is a flick that coasts. With the fix, a pull inside a scrolled box scrolls the box, and a pull from the box's top drags the sheet as before.

Problem and solution fit

Why it occurs: useSheetGestures listens on the body and decides the handoff by the body's own scroll edge (atTop(scroller) at touchstart, scrollTop <= 0 on the pointer path). A nested scroller moves its own scrollTop, never the body's, so the body reports "at the top" for every touch and the first downward touchmove is cancelled and promoted to a sheet drag.

Why it harms the task: the sheet's one scrolling gesture is taken from the content. A picker whose results sit in a scrolling grid can be scrolled down but not up; the user's correction (a pull down) is read as "close".

Why it matters: this is the common sheet layout (header, scrolling content, footer), and the failure is silent and repeatable on every such sheet.

The fix reads the edge of the innermost scrollable box between the touch target and the body (scrollerUnder), in the touch path and the pointer path. A box with nothing to scroll leaves the decision to the body, so sheets whose content scrolls the body itself are unchanged.

Expected behavior and authority

The hook's own contract (file header and the body touch handoff tests): the scrolling body hands the gesture to the sheet at a scroll edge; mid-content, native scrolling is left alone. No current record claims the handoff; this restores the contract's intent for a scroller nested inside the body.

Smallest restoration

One helper (scrollerUnder), used where the edge is read: touchstart arming, the touchmove promotion checks, the content-end handoff, and the pointer path's arming. No API, visual, default, or layout change. Out of scope and separable: a mid-gesture hand-back when a nested box reaches its top while the finger keeps pulling (the top-edge analog of the existing contentEndY bottom handoff).

Evidence

  • Reproduction before the change: a sheet with a scrolling grid inside its body, Chromium phone emulation (390x844, touch). Scroll the grid 43px, pull down 160px over it: the sheet translated 160px, the grid stayed at 43px. The new tests fail on main (leaves a pull-down to a nested scroller that is scrolled, leaves a pull-up to a nested scroller with content below, arms the pointer path on the nested scroller too: expected true to be false).
  • Result after the change: the same pull scrolls the grid back to 0 and the sheet does not move; a second pull from the grid's top drags the sheet and dismisses it past the line.
  • Representative unchanged path: promotes a top pull-down (touch) into a sheet drag and the rest of the existing 47 cases pass unchanged; a nested box with nothing to scroll still promotes (reads the body when the nested box has nothing to scroll).
  • Regression test or other mutation-sensitive proof: useSheetGestures.test.ts > body touch handoff from a nested scroller (5 cases, 3 red on main).

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

pnpm vitest run packages/core/src/BottomSheet/useSheetGestures.test.ts
 Test Files  1 passed (1)
      Tests  52 passed (52)
pnpm exec eslint packages/core/src/BottomSheet/useSheetGestures.ts packages/core/src/BottomSheet/useSheetGestures.test.ts   # clean
pnpm --filter @astryxdesign/core exec tsc --noEmit   # clean

Real browser: Chromium phone emulation as above, before/after on a host app's picker sheet (scroll the grid, pull down over it, pull from its top). Not yet run on an iOS device; the mechanism (the non-passive touchmove cancel on the first move) is unchanged, only which element's edge is read.

@vercel

vercel Bot commented Oct 8, 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 8, 2026 12:32pm UTC

Request Review

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

astracat-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 8, 2026, 12:40 PM UTC

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

Thanks — reading the scroll edge of the box under the finger is the right direction, and the new nested-scroller cases cover the pinned header/footer layout well. One blocking issue before this can land:

  • When the nested box is at its edge but an ancestor scroller — including the sheet body itself — can still scroll in that direction, the gesture should chain to that ancestor before the sheet takes over. As written, scrollerUnder returns only the nearest box and its edge alone arms the handoff, so a pull down over a nested box at its top while the body is scrolled drags the sheet instead of scrolling the body back (the bottom/content-end path has the same shape). The new tests can't catch this because their fixture body has nothing to scroll. Please promote only once the whole chain from the touch target up to and including the body is exhausted in the pull direction, and add regression cases with a scrollable body: nested box at its top with the body scrolled leaves the pull to native scrolling, nested box at its bottom with the body not at its bottom does not expand the sheet, and both exhausted together still promotes as today.

With that condition in place this looks good to land.

[Automated review]

…inger

The scrolling body hands a touch to the sheet at a scroll edge, and it read
that edge off itself. Content that scrolls in a box of its own inside the
body (a pinned header and footer around a scrolling middle, a grid) moves
that box's scrollTop and never the body's, so the body reported "at the top"
for every touch: a pull meant to scroll the inner box back up dragged the
sheet instead, and the box could never be scrolled back by hand.

The edge that decides the handoff is now read off every scroller under the
finger, the boxes nested between the touch target and the body and the body
itself (scrollChainUnder), in the touch path and the pointer path alike. The
browser scrolls the innermost box with room and chains outward, so the
sheet's turn comes only once the whole chain is at the edge the pull
opposes: a nested box at its top over a scrolled body still scrolls the
body. A box with nothing to scroll leaves the decision to the rest of the
chain, as before.
@vjeux
vjeux force-pushed the sheet-nested-scroll branch from c40beb8 to da815a7 Compare October 8, 2026 12:25
@vjeux

vjeux commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Addressed in da815a7: the handoff now reads the whole chain under the finger (the nested boxes and the body) and arms only when every box is at the edge the pull opposes, so a nested box at its top over a scrolled body chains to the body as the browser does. Case added: chains to a scrolled body before the sheet when the nested box is at its top.

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

Thanks — this now looks good to land. Reading the whole chain under the finger fixes the pinned header/footer layout where a scrolled inner box could never be pulled back up, and requiring every box up to the body to be at the opposed edge preserves normal chaining: a nested box at its top over a scrolled body scrolls the body first, and the sheet only takes over once nothing under the finger can move that way. Verified in both directions, including the bottom and mid-gesture content-end paths, with the full hook suite, lint, and typecheck passing and no public API change.

[Automated review]

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

No new or modified components detected.

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

23 of 442 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 155,733
Chat Full AI Chat probe dark 155,005
Chat Default neutral dark 33,205
Chat Default neutral light 32,876
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,229
Chat With Attachments probe dark 11,065
TableRowExpansion Detail Panel neutral dark 5,129
TableRowExpansion Detail Panel neutral light 4,050
SideNav Resizable in AppShell probe light 3,208
TableGroupedRows Default neutral light 2,133
TableGroupedRows Default neutral dark 2,116
Markdown Default probe dark 897
Markdown Default probe light 897
Markdown Default neutral dark 882

and 3 more.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@imdreamrunner
imdreamrunner merged commit 437ea17 into meta:main Oct 8, 2026
40 checks passed
@vjeux
vjeux deleted the sheet-nested-scroll branch October 8, 2026 19:54
cixzhang added a commit that referenced this pull request Oct 8, 2026
#7188)

#7168 added "promotes a pull-down from the top of a nested scroller", which
asserted the sheet's position through `dragOffset`. #7169 merged 90 seconds
later from a base without that test: it moved the live drag position out of
React state (to `activeOffsetRef` and the element's transform) and redefined
`dragOffset` as the offset last rendered for a layout-split change, migrating
every existing assertion but not this new one. The product still promotes the
pull-down and moves the sheet 60px; only the stale read fails, on main and on
every PR.

Assert the live offset and the transform written to the sheet element, as the
other drag assertions do since #7169.

This branch was successfully deployed

1 active deployment
Preview — da815a7f Deployed Oct 8, 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