Skip to content

[drawer] Preserve cross-axis scrolling during touch gestures#4187

Merged
atomiks merged 5 commits intomui:masterfrom
atomiks:codex/drawer-4180-cross-axis-scroll
Mar 4, 2026
Merged

[drawer] Preserve cross-axis scrolling during touch gestures#4187
atomiks merged 5 commits intomui:masterfrom
atomiks:codex/drawer-4180-cross-axis-scroll

Conversation

@atomiks
Copy link
Contributor

@atomiks atomiks commented Feb 24, 2026

Fixes drawer touch handling so cross-axis scrolling remains native (for example, vertical scroll inside side drawers and horizontal scroll inside top/bottom drawers) instead of being incorrectly blocked by swipe-dismiss prevention

Fixes #4180

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

pkg-pr-new bot commented Feb 24, 2026

commit: c4a31a3

@mui-bot
Copy link

mui-bot commented Feb 24, 2026

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+566B(+0.12%) 🔺+222B(+0.15%)

Details of bundle changes


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

@netlify
Copy link

netlify bot commented Feb 24, 2026

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit b620f2d
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69a7bf494ee01c0008c7f3b2
😎 Deploy Preview https://deploy-preview-4187--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

@atomiks atomiks force-pushed the codex/drawer-4180-cross-axis-scroll branch from faa8bef to e48a317 Compare February 24, 2026 23:43
@CiscoFran10
Copy link
Contributor

I tested this on iOS and found this issue.

On Chrome (iOS), if I scroll the page vertically and then open a left drawer (swipeDirection="left", Y overflow) while the scrollbar still visible, I’m still able to scroll the underlying page after the drawer opens. On Safari this doesnt happen.

bug-chrome.mp4

@CiscoFran10
Copy link
Contributor

I tested this on iOS and found this issue.

On Chrome (iOS), if I scroll the page vertically and then open a left drawer (swipeDirection="left", Y overflow) while the scrollbar still visible, I’m still able to scroll the underlying page after the drawer opens. On Safari this doesnt happen.

bug-chrome.mp4

This is a pretty unlikely edge case, so it’s not something users would commonly hit, but, it might still be worth exploring. I’m not sure whether this scroll leakage could lead to other issues.

@atomiks
Copy link
Contributor Author

atomiks commented Feb 25, 2026

On Safari this doesnt happen

Interesting. Usually iOS is the same no matter the browser due to the underlying WebKit engine, so it's a bit annoying when they diverge. Not sure if this is fixable or if it's a browser quirk as scroll locking on iOS without issues is really hard.

@github-actions github-actions bot added PR: out-of-date The pull request has merge conflicts and can't be merged. and removed PR: out-of-date The pull request has merge conflicts and can't be merged. labels Mar 2, 2026
@atomiks
Copy link
Contributor Author

atomiks commented Mar 3, 2026

Codex Review

Overview

This branch addresses drawer cross-axis touch scrolling by latching native cross-axis intent during a gesture, adds targeted regression coverage for jitter and mixed-axis cases, and introduces an experiments matrix/demo for manual verification.

Findings

1. [Non-blocking] Reduce duplication in the new cross-axis regression tests

Impact: The four axis-specific skipIf(isJSDOM) tests are near-identical and differ mostly by swipeDirection, overflow style, and gesture vectors. Keeping them hand-expanded increases maintenance overhead and makes it easier for one case to drift from the others during future edits.

Evidence: packages/react/src/drawer/viewport/DrawerViewport.test.tsx:1608, packages/react/src/drawer/viewport/DrawerViewport.test.tsx:1654, packages/react/src/drawer/viewport/DrawerViewport.test.tsx:1700, packages/react/src/drawer/viewport/DrawerViewport.test.tsx:1746 share the same render/interaction/assertion structure with minor parameter changes.

Recommendation: Convert these into a table-driven test (it.each) with a small case matrix (swipeDirection, overflowStyle, start/move coordinates, expected swiping attr). This preserves coverage while reducing surface area and copy/paste risk.

2. [Informational] Touchmove hot-path perf check does not show actionable regression signal

Impact: The cross-axis helper sits on a hot touchmove path, so validating overhead is important; however, the current micro-check indicates sub-microsecond per-call cost where practical impact is likely negligible.

Evidence: Lightweight benchmark (node /tmp/drawer-touch-helper-bench.mjs) measured: baseline update-only 7.71ms / 10M calls (0.001us/call), helper fast-return 38.41ms (0.004us/call), helper latched-return 38.05ms (0.004us/call).

Recommendation: No immediate code change required for runtime perf based on this check; continue relying on bundle-size CI/snapshot signals for shipped size tracking.

No blocking issues found in this patch.

Confidence: 4/5

High confidence from full-branch inspection, targeted touch-path review, and rerunning relevant checks; residual uncertainty is mostly around platform-specific touch behavior that only broad device coverage can fully validate.

Notes

  • Full-branch pass covered all files changed vs upstream/master (drawer runtime logic, drawer tests, and experiments route/demo files).
  • Validation run: pnpm typescript, pnpm test:jsdom DrawerViewport --no-watch, pnpm test:chromium DrawerViewport --no-watch.

@atomiks atomiks force-pushed the codex/drawer-4180-cross-axis-scroll branch 2 times, most recently from 88a3cef to c847c65 Compare March 4, 2026 04:27
@atomiks atomiks force-pushed the codex/drawer-4180-cross-axis-scroll branch from 83fa7a5 to 1ceeca4 Compare March 4, 2026 05:04
@atomiks atomiks merged commit 529ae37 into mui:master Mar 4, 2026
20 of 22 checks passed
@atomiks atomiks deleted the codex/drawer-4180-cross-axis-scroll branch March 4, 2026 05:17
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] Cannot scroll vertically inside left/right drawers on touch devices

3 participants