Repository navigation
fix(core): BottomSheet reads the scroll edge of the box under the finger - #7168
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
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,
scrollerUnderreturns 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.
c40beb8 to
da815a7
Compare
|
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: |
There was a problem hiding this comment.
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]
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewNo new or modified components detected. Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual Regression23 of 442 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 3 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
#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.
User impact
Anyone using a
BottomSheeton 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:
useSheetGestureslistens on the body and decides the handoff by the body's own scroll edge (atTop(scroller)attouchstart,scrollTop <= 0on the pointer path). A nested scroller moves its ownscrollTop, never the body's, so the body reports "at the top" for every touch and the first downwardtouchmoveis 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 handofftests): 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:touchstartarming, thetouchmovepromotion 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 existingcontentEndYbottom handoff).Evidence
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).promotes a top pull-down (touch) into a sheet dragand 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).useSheetGestures.test.ts>body touch handoff from a nested scroller(5 cases, 3 red onmain).Scope
Testing
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
touchmovecancel on the first move) is unchanged, only which element's edge is read.