Skip to content

fix(core): a bottom-edge pull-up no longer hijacks a fully expanded Bottom Sheet - #5161

Merged
imdreamrunner merged 1 commit into
mainfrom
codex/bottom-sheet-scroll-drag-handoff
Aug 17, 2026
Merged

imdreamrunner merged 1 commit into
mainfrom
codex/bottom-sheet-scroll-drag-handoff

Conversation

@imdreamrunner

@imdreamrunner imdreamrunner commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

At its tallest detent, a Bottom Sheet with scrolled content stole an upward
pull that belonged to the scroller. The sheet lifted a little, stopped short of
the finger, and sprang back — and for the rest of that gesture the content
could not scroll at all.

onTouchStart armed the bottom edge for handoff whenever the scroller was at
its end, without asking whether the sheet had anywhere to expand to. At the
tallest detent baseOffset === 0, so every upward pixel landed in the
rubber-band branch of handlePointerMove (OVERSCROLL_RESISTANCE = 0.35,
capped at OVERSCROLL_MAX = 48) and settleFromDrag returned it to 0. The
measured lift was exactly min(0.35 × d, 48), thrown back over ~225ms.

The worse half is the captured gesture. Once promoted, dragStateRef is
set and every later touchmove is preventDefault()ed, so native scrolling
stays dead until the finger lifts. Overshoot the end of a list by a few pixels,
drag back to scroll, and the sheet collapses a detent instead — from a mid
detent the same gesture drove the sheet to top: 810 on a 900px viewport, one
nudge from dismissal.

The bottom edge hands off so the sheet can expand, so it is only a handoff
when a taller detent exists:

const bottom = atBottom(scroller) && activeOffsetRef.current > 0;

activeOffsetRef is refreshed every render and equals settledOffset when no
drag is in flight, so it is the live answer to "is there room to expand" — no
new state, no stale closure.

Measured

Capped-height story, 500×900, content scrolled to the bottom:

finger up lift before lift after
20px 7px 0px
80px 28px 0px
320px 48px 0px

One gesture, fully open: pull up 60px, then reverse down 300px.

before after
sheet top 342 → 450 (collapsed a detent) 342 (stays)
scrollTop 367 → 367 (dead) 367 → 0 (scrolls)

Unchanged and re-verified: top-edge pull-down collapse, mid-detent
expand-by-pull-up (450 → 342), fully-open + at-top + finger-up scrolling, and
scrollPreservationInset healing. Same on the hug-height story.

Risk

Public API unchanged. One deliberate behavior change beyond the bug: on a sheet
whose content does not scroll at all, atTop and atBottom are both true, so
an upward pull used to rubber-band there too. It no longer does. The body
already sets overscrollBehavior: 'none', so "no bounce at the end" is the
established choice here, and the grab handle remains the affordance for moving
the sheet. Happy to restore the bounce for that case if reviewers prefer it.

Touch-only. The pointer path never armed the bottom edge —
handleBodyPointerDown returns early when scrollTop > 0 — so mouse-driven
harnesses cannot see any of this, before or after.

Testing

useSheetGestures.test.ts — the existing case asserted only
isDragging === true, which the bug satisfied: the promotion was real, the
travel was worthless. It now asserts the sheet actually follows the finger, and
two regressions pin the tallest detent:

  • promotes a bottom pull-up (touch) into a sheet drag that travels — settles
    at a lower detent first, then asserts dragOffset tracks the finger 1:1
  • leaves a bottom pull-up with the scroller at the tallest detent
  • does not preventDefault a bottom pull-up at the tallest detent — pins the
    reversal case via defaultPrevented

Both regressions fail on the unfixed source and pass with the fix.

  • vitest run packages/core/src/BottomSheet/ — 142 pass
  • pnpm check:repo, eslint, tsc --noEmit — clean
  • Browser: real CDP touch events at 500×900 against both long-content stories

Scope

This PR only stops the sheet from taking a gesture it cannot use. The
scroll-to-the-bottom-then-pull-up handoff is unchanged and verified: at a mid
detent with content at its end, an upward pull tracks the finger 1:1 (40px →
40.0, 60px → 60.0, 80px → 80.0) and settles expanded. Direct expansion from any
scroll position remains the grab handle's job.

Whether an upward drag should expand a sheet beyond its opening height is a
separate question, tracked in #5087.

…ottom Sheet

At the tallest detent an upward pull at the end of the scrolling content was
promoted into a sheet drag with nowhere to expand to. The travel landed in the
rubber-band branch (0.35x, capped at 48px) and the release threw it straight
back, and — because promotion preventDefault()s the rest of the gesture — the
scroller stayed dead until the finger lifted, so reversing downward to scroll
back collapsed the sheet a detent instead of scrolling.

Arm the bottom edge for handoff only when a taller detent exists. The top-edge
pull-down handoff and the mid-detent expand are unchanged.

The old test asserted only that the promotion happened; it now asserts the
sheet actually travels, plus two regressions for the tallest detent.
@vercel

vercel Bot commented Aug 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview Aug 17, 2026 7:04pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

BottomSheet (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 2978 -
Complexity N/A Very High (245) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.8KB 1.2KB

Accessibility Audit

Status: No accessibility violations detected.


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

github-actions Bot added a commit that referenced this pull request Aug 17, 2026
@imdreamrunner
imdreamrunner marked this pull request as ready for review August 17, 2026 19:32
@imdreamrunner
imdreamrunner marked this pull request as draft August 17, 2026 19:37
@imdreamrunner
imdreamrunner marked this pull request as ready for review August 17, 2026 20:03
@imdreamrunner
imdreamrunner merged commit 8704600 into main Aug 17, 2026
26 checks passed
imdreamrunner added a commit that referenced this pull request Aug 18, 2026
…5172)

A swipe that scrolls to the end of the sheet's content and keeps pulling
stopped dead at the last line. Arming was decided once, at touchstart: a
finger that landed mid-content stayed a scroll for the whole gesture, so
the motion people actually perform -- swipe up through the list, reach
the bottom, keep pulling -- never reached the sheet. Only a fresh touch
that started already at the edge handed off, which is why every scripted
repro said the bottom edge was fine.

Re-arming on every move and promoting with preventDefault() cannot fix
it: once the browser has committed the gesture to scrolling, the
remaining touchmoves are non-cancelable (measured in Chrome: 40 moves in
the gesture, 12 with the scroller at its end, 0 of them cancelable).
Nothing needs cancelling either -- the scroller is clamped at its
maximum, so further upward travel scrolls nothing.

So the body now tracks every touch, notes where the finger was when the
content ran out, and drives the sheet from the travel beyond that point:
no jump, and the part of the swipe that legitimately scrolled stays with
the content. The handoff yields again if the finger comes back down (the
native scroll it handed off from was never cancelled, and two things
moving at once is the failure mode), and never fires with no taller
detent to expand into, the #5161 rule.

Verified in Chrome (~/sheet-repro/continuous-handoff-suite.mjs): the
continuous pull expands the sheet 450 -> 342, while mid-content
scrolling, the top-edge pull-down, the momentum tail, the reversal, and
the tallest-detent case are unchanged.
@github-actions
github-actions Bot deleted the codex/bottom-sheet-scroll-drag-handoff branch August 18, 2026 06:11

This branch was successfully deployed

1 active deployment
Preview — 3e7c1af4 Deployed Aug 17, 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.

1 participant