Repository navigation
[drawer] Fix cross-axis scroll blocked on iOS below the touchmove slop - #5257
Conversation
commit: |
Bundle size
PerformanceTotal duration: 1,398.78 ms +30.55 ms(+2.2%) | Renders: 78 (+0) | Paint: 2,195.25 ms +41.08 ms(+1.9%)
13 tests within noise — details Check out the code infra dashboard for more information about this PR. |
✅ Deploy Preview for base-ui ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
Pull request overview
This PR fixes an iOS Safari interaction bug in Base UI’s DrawerViewport touch handling where preventing the first cancelable touchmove could cancel native scrolling for the entire gesture, intermittently blocking cross-axis scrolling inside left/right drawers. The updated logic defers claiming the gesture until one axis clearly “wins” (passes the slop), and yields when the browser has already committed the gesture to native scrolling.
Changes:
- Add explicit axis-lock constants and update axis-attribution logic to avoid preventing sub-slop ambiguous gestures.
- Yield swipe handling when
touchmoveis non-cancelable (native scroll already committed) to avoid dragging the popup during scrolling. - Add focused tests covering sub-slop first moves, post-slop axis claiming, and the non-cancelable iOS-style case.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/react/src/drawer/viewport/DrawerViewport.tsx | Updates touchmove axis-locking/gesture-claiming to preserve native cross-axis scrolling on iOS and yield on non-cancelable moves. |
| packages/react/src/drawer/viewport/DrawerViewport.test.tsx | Adds regression tests validating the new “don’t prevent sub-slop” and “yield on non-cancelable” behaviors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Ports the six applicable Drawer fixes from the base-ui v1.7.0 release: - mui/base-ui#5105: reliable swipe-to-open — first-move re-anchoring is now gated on trackDrag (the SwipeArea passes trackDrag: false, so a flick whose whole travel lands in the first move still registers), and sawPrimaryButtonsOnMove initializes from the event type. - mui/base-ui#5308: drag styles are only rewritten when the offset actually changed, fixing the snap point jump when the pointer is pinned at a screen edge. The swipeThreshold function is snapshotted at gesture start. - mui/base-ui#5257: cross-axis touch arbitration rewritten (shouldYieldTouchMove) — 6px slop / 2px bias, one-shot attribution per gesture, non-cancelable moves yield to native scroll, and no preventDefault until an axis passes the slop (iOS kills native scrolling for the whole gesture otherwise). - mui/base-ui#5360: elementFromPoint resolves through getRootNode() so swipe gestures work inside shadow DOM. - mui/base-ui#5112: the popup no longer flashes fully open for a frame during a swipe-area open — resetAfterOpen skips the movement-var reset while the SwipeArea drives the gesture (swipeAreaActive), and the SwipeArea re-asserts its styles when the popup (re)mounts. - mui/base-ui#5179: virtual keyboard scroll handling rework for focus moves while the keyboard is open — interval realign passes, preemptive focus geometry override to neutralize WebKit's reveal scroll, window scroll pinning, programmatic-focus flag, settle-watching scroll bookkeeping. The SwipeArea outside-press guard is now deterministic (capture-phase pointerdown/click listeners + isVirtualClick) instead of a 300ms timer. Not ported (React-only): mui/base-ui#5109, Drawer.Handle/createHandle detached triggers, bundle-size refactors. Co-Authored-By: Claude Fable 5 <[email protected]>
Closes #5255
Vertical scrolling inside a left/right drawer intermittently failed on iOS.
DrawerViewport's touchmove handler treated any gesture below the 6px cross-axis threshold as a drawer swipe and calledpreventDefault(). On iOS, preventing the first cancelabletouchmovecancels native scrolling for the entire gesture, so a drag whose first move landed under the threshold could never scroll, no matter how far it traveled afterwards.Gestures that haven't traveled past the slop on either axis are now left alone — neither prevented nor claimed for the swipe — until one axis wins. A non-cancelable move (the browser already committed to a native scroll) now also yields the gesture instead of dragging the popup alongside the scrolling content. The trade-off is inherent to iOS: the swipe can only be claimed once the drawer axis passes the slop, so it starts ~6px later over cross-axis scrollable content.
Manually verified on the iOS Simulator with the
drawer/cross-axis-scrollexperiment.