Skip to content

fix(Drawer): let touch swipes start on interactive elements - #2982

Merged
zernonia merged 1 commit into
v2from
fix/drawer-swipe-ignore-selector
Sep 30, 2026
Merged

zernonia merged 1 commit into
v2from
fix/drawer-swipe-ignore-selector

Conversation

@zernonia

@zernonia zernonia commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

🔗 Linked issue

Closes #2907

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

useSwipeDismiss skipped any touch that started on a button, a, label, field or [role="button"]. A drawer made mostly of these (a nav list, an action sheet, checkbox rows) could barely be dragged on touch devices.

This PR ports what Base UI does (mui/base-ui#4295). Base UI's DrawerViewport passes ignoreSelectorWhenTouch: false:

  • Touch can start a swipe on interactive elements. A tap that stays under the drag threshold still clicks. Range inputs are still skipped, because dragging the thumb looks the same as a swipe.
  • Mouse and pen still skip interactive elements, so clicks and text selection work as before.
  • data-reka-swipe-ignore (the equivalent of data-base-ui-swipe-ignore) stops a swipe from starting on an element and its children, for every input type. Use it for carousels, maps, signature pads and similar controls.

I didn't add a configurable selector prop or make canStart able to force a swipe, both of which the issue suggested. Base UI has neither, and the touch change plus the opt-out attribute cover the cases in the issue.

Docs: a new "Where a swipe can start" example in the Drawer page.

Tests: new useSwipeDismiss cases check that:

  • a touch swipe starts on a link, a button and a label
  • a touch on a range input or on a data-reka-swipe-ignore subtree is left to the element
  • a mouse press on a button or on an ignored subtree doesn't start a swipe
  • a mouse swipe on plain content still works

On the old code, the link, button, label and ignore-attribute cases fail.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Touch swipes can now start on interactive drawer content. Gestures that don’t exceed the drag threshold still activate clicks.
    • Add data-reka-swipe-ignore to prevent swipe gestures from starting on an element, regardless of input type.
    • Mouse and pen swipes continue to skip interactive elements.

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) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: unovue/reka-ui/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 5bad0e5b-1929-4f29-8aa8-266a89c24c75

📥 Commits

Reviewing files that changed from the base of the PR and between 67409e4 and 12ff8c7.

📒 Files selected for processing (4)
  • docs/content/docs/components/drawer.md
  • packages/core/src/Drawer/DrawerContentImpl.vue
  • packages/core/src/Drawer/composables/useSwipeDismiss.test.ts
  • packages/core/src/Drawer/composables/useSwipeDismiss.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.


📝 Walkthrough

Walkthrough

Drawer swipe-dismiss now allows touch swipes to start on most interactive content, while continuing to exclude range inputs and elements marked with data-reka-swipe-ignore. Pointer swipes continue to exclude interactive elements. The documentation describes these rules.

Changes

Drawer swipe start rules

Layer / File(s) Summary
Swipe start rules and Drawer integration
packages/core/src/Drawer/composables/useSwipeDismiss.ts, packages/core/src/Drawer/DrawerContentImpl.vue, packages/core/src/Drawer/composables/useSwipeDismiss.test.ts, docs/content/docs/components/drawer.md
UseSwipeDismissOptions adds ignoreSelectorWhenTouch, which defaults to true; Drawer sets it to false. Touch starts still ignore range inputs and targets marked with data-reka-swipe-ignore. Pointer starts ignore interactive elements and targets marked with that attribute. Tests and documentation cover the behavior.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 12ff8

The change enables touch swipes on interactive Drawer content while retaining pointer exclusions and explicit opt-outs. No concrete merge-blocking issue is established; merge after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to 12ff8

This is a narrowly scoped interaction change. Existing dismissal guards, range-input protection, and explicit swipe exclusions remain. No privilege or data-access expansion was identified, but concurrent-touch and browser-specific click behavior remain partially verified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The demonstrated expansion is local gesture reachability: touches beginning on interactive Drawer descendants can now affect movement, snapping, and dismissal. The inspected path introduces no new privileged sink; effects remain within the existing DOM updates and caller-owned callbacks. Other external composable consumers were not exhaustively established.

Trust Boundaries and Controls

  • observed — Gesture eligibility remains guarded before state creation. Explicitly ignored descendants are rejected through closest(), range inputs remain excluded from opted-in touch starts through composedPath(), and pointer starts continue rejecting interactive targets.

Resilience and Maintainability Implications

  • observed — Touch processing uses touches[0] rather than a tracked touch identifier, and each accepted start resets the shared gesture state. The changed surface modifies initiation eligibility rather than this existing ownership mechanism. Concurrent-touch isolation remains unverified, without evidence of a security-control bypass.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 2 files. (2 skipped: 2… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: allowing touch swipes to start on interactive Drawer elements.
Linked Issues check ✅ Passed The PR addresses the active coding objective in [#2907]. Touch swipes can start on interactive content such as links, buttons, labels, and role buttons. Range inputs remain protected. The `data-reka-s…
Out of Scope Changes check ✅ Passed The changes stay within [#2907]. The implementation changes swipe-start filtering, the tests verify the filtering, and the Drawer documentation explains the behavior and opt-out attribute. No unrelate…
Full details: Docstring Coverage

Explanation

Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 2 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pkg-pr-new

pkg-pr-new Bot commented Sep 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/reka-ui@2982

commit: 12ff8c7

@zernonia
zernonia merged commit abb7413 into v2 Sep 30, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Drawer: DEFAULT_IGNORE_SELECTOR blocks swipe-dismiss on most of the drawer surface, with no way to configure or disable it

1 participant