Skip to content

[drawer] Make data-base-ui-swipe-ignore explicit for touch interactions - #4295

Merged
atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/drawer-swipe-ignore-touch
Mar 12, 2026
Merged

atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/drawer-swipe-ignore-touch

Conversation

@atomiks

@atomiks atomiks commented Mar 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #4294

Summary

This changes swipe-ignore handling so Drawer and Toast use the namespaced data-base-ui-swipe-ignore attribute, while Toast still accepts the legacy data-swipe-ignore alias for compatibility.

For Drawer specifically:

  • Drawer.Content no longer auto-adds a public swipe-ignore attribute.
  • Touch taps on non-interactive elements inside Drawer.Content still fire onClick without requiring data-base-ui-swipe-ignore.
  • data-base-ui-swipe-ignore now acts as the explicit opt-out for swipe dismissal, matching the Vaul-style behavior for the full touch gesture.
  • Mouse and pen interactions on Drawer.Content still avoid swipe handling so text selection keeps working.

The patch also adds focused regression coverage for Drawer and Toast, updates the docs, and includes a small private experiment page for manual touch testing.

@atomiks atomiks added component: drawer Changes related to the drawer component. type: bug It doesn't behave as expected. labels Mar 11, 2026
@atomiks

atomiks commented Mar 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Codex Review

Overview

This patch makes swipe opt-out explicit with data-base-ui-swipe-ignore, keeps Drawer.Content focused on mouse and pen text selection, and preserves the old toast attribute for compatibility. It also keeps touch taps working on non-interactive drawer content, centralizes the elementFromPoint fallback, and adds regression coverage for the updated gesture paths.

Findings (None)

No blocking issues found in this patch.

Confidence: 5/5

High confidence after a full review of the branch diff against master, plus a second sweep across React/DOM behavior, accessibility, API design, maintainability, performance, and test coverage. The exercised tests cover the changed gesture paths in JSDOM and Chromium.

Notes

  • Reviewed the full branch diff for PR [drawer] Make data-base-ui-swipe-ignore explicit for touch interactions #4295, not only the latest commit.
  • Latest changes since the previous review are wording-only test updates; the underlying behavior and coverage remain consistent.
  • Drawer now only honors the namespaced swipe-ignore attribute, while Toast keeps the legacy alias for compatibility.

@pkg-pr-new

pkg-pr-new Bot commented Mar 11, 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@4295
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@4295
    

commit: 3a71f89

@mui-bot

mui-bot commented Mar 11, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 🔺+340B(+0.07%) 🔺+92B(+0.06%)

Details of bundle changes


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

@netlify

netlify Bot commented Mar 11, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 5780057
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69b23d25ccb29000088844a8
😎 Deploy Preview https://deploy-preview-4295--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 changed the title [drawer] Make data-swipe-ignore explicit for touch interactions [drawer] Make data-base-ui-swipe-ignore explicit for touch interactions Mar 11, 2026
@atomiks
atomiks force-pushed the codex/drawer-swipe-ignore-touch branch 4 times, most recently from b035755 to bb4641f Compare March 11, 2026 01:40
@atomiks
atomiks marked this pull request as ready for review March 11, 2026 01:44
@atomiks
atomiks force-pushed the codex/drawer-swipe-ignore-touch branch from bb4641f to 378f220 Compare March 11, 2026 01:51
@atomiks
atomiks force-pushed the codex/drawer-swipe-ignore-touch branch from e070f6a to e392b53 Compare March 12, 2026 04:09
@atomiks
atomiks merged commit 227b360 into mui:master Mar 12, 2026
3 of 6 checks passed
@atomiks
atomiks deleted the codex/drawer-swipe-ignore-touch branch March 12, 2026 04:18
@doruksahin

Copy link
Copy Markdown

Thanks @atomiks :D
That was fast

zernonia added a commit to unovue/reka-ui that referenced this pull request Sep 30, 2026
Touch swipes skipped buttons, links, labels and fields, so drawers built
from them (nav links, action sheets, checkbox rows) could not be dragged.
Port Base UI's behavior: touch ignores the interactive-element selector
(`ignoreSelectorWhenTouch: false`) and only keeps range inputs out, while
mouse and pen still skip interactive elements. Add `data-reka-swipe-ignore`
to opt an element out for every input type (mui/base-ui#4295).

Closes #2907

Co-authored-by: Claude Opus 5.5 (1M context) <[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] Swipe dismiss handler blocks onClick on non-interactive elements inside drawer on touch devices

3 participants