Skip to content

[drawer] Fix cross-axis scroll blocked on iOS below the touchmove slop - #5257

Merged
atomiks merged 3 commits into
mui:masterfrom
atomiks:claude/base-ui-issue-5255-083ba8
Jul 19, 2026
Merged

atomiks merged 3 commits into
mui:masterfrom
atomiks:claude/base-ui-issue-5255-083ba8

Conversation

@atomiks

@atomiks atomiks commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

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 called preventDefault(). On iOS, preventing the first cancelable touchmove cancels 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-scroll experiment.

@atomiks atomiks added component: drawer Changes related to the drawer component. type: bug It doesn't behave as expected. labels Jul 16, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 16, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@5257
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@5257
    

commit: f13973d

@code-infra-dashboard

code-infra-dashboard Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+163B(+0.04%) 🔺+58B(+0.04%)

Details of bundle changes

Performance

Total duration: 1,398.78 ms +30.55 ms(+2.2%) | Renders: 78 (+0) | Paint: 2,195.25 ms +41.08 ms(+1.9%)

Test Duration Renders
Tabs mount (200 instances) 249.00 ms 🔺+43.65 ms(+21.3%) 3 (+0)
Combobox type — 500 items, narrows to ~11 (type "Row 25") 33.62 ms ▼-8.95 ms(-21.0%) 15 (+0)

13 tests within noise — details


Check out the code infra dashboard for more information about this PR.

@netlify

netlify Bot commented Jul 16, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit f13973d
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a5d583a6b71170008757a2f
😎 Deploy Preview https://deploy-preview-5257--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks
atomiks marked this pull request as ready for review July 17, 2026 07:16
@atomiks
atomiks requested a review from Copilot July 19, 2026 22:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 touchmove is 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.

@atomiks
atomiks merged commit f0478fa into mui:master Jul 19, 2026
6 checks passed
@atomiks
atomiks deleted the claude/base-ui-issue-5255-083ba8 branch August 11, 2026 03:01
legowhales added a commit to legowhales/svelte-base-drawer that referenced this pull request Aug 13, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: drawer Changes related to the drawer component. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[drawer] Cross-axis scroll still blocked on iOS below the 6px touchmove threshold (#4187 residual)

2 participants