Skip to content

fix(drawer): cancel react-aria presses when a swipe starts - #703

Open
mehdibha wants to merge 1 commit into
mainfrom
claude/docs-search-drawer-drag-b43c5c
Open

fix(drawer): cancel react-aria presses when a swipe starts#703
mehdibha wants to merge 1 commit into
mainfrom
claude/docs-search-drawer-drag-b43c5c

Conversation

@mehdibha

@mehdibha mehdibha commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary

  • Dragging the docs search drawer from a result navigated to that result on release. Every Drawer was affected, not just search.
  • Root cause: react-aria's usePress only cancels on pointercancel / pointerleave / dragstart. During a swipe none fire — the content moves with the finger so the pointer never leaves the item, and base-ui calls preventDefault on touchmove so the browser never takes over the gesture. On release the press is still live; usePress waits 80ms for a native click and, finding none, calls target.click() itself (its iOS long-press workaround). That synthesized click navigates.
  • Fix: the popup element now renders through a small DrawerPopupElement that reads base-ui's swiping state and dispatches a pointercancel on the document when a swipe starts — the same signal the platform sends when a gesture is claimed. In-flight presses cancel and the item un-highlights as the drag begins.

Verification

Headless Chrome + Puppeteer touch events, 375px viewport, docs search drawer:

Scenario Before After
Drag 180px from the "Docs" item swipe engaged, item clicked, navigated swipe engaged, no click, no navigation
Plain tap on an item navigates and closes
Long swipe dismisses without navigating

pnpm check, tsc --noEmit pass; pnpm build:registry produced no tracked changes.

Dragging a drawer from a pressable (e.g. a search result) fired the press on
release: the content moves with the finger so the pointer never leaves the
item, and the drawer claims the gesture so the browser never emits
pointercancel. usePress then synthesizes a click after 80ms. Dispatch a
pointercancel on the document when base-ui reports swiping.
@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
dotui Ready Ready Preview Sep 2, 2026 1:41am UTC

@github-actions github-actions Bot added area: www The dotui.org app: site, landing, docs pages area: registry Registry source and generated output (www/src/registry) labels Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: registry Registry source and generated output (www/src/registry) area: www The dotui.org app: site, landing, docs pages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant