fix(drawer): cancel react-aria presses when a swipe starts - #703
Open
mehdibha wants to merge 1 commit into
Open
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
usePressonly cancels onpointercancel/pointerleave/dragstart. During a swipe none fire — the content moves with the finger so the pointer never leaves the item, and base-ui callspreventDefaultontouchmoveso the browser never takes over the gesture. On release the press is still live;usePresswaits 80ms for a native click and, finding none, callstarget.click()itself (its iOS long-press workaround). That synthesized click navigates.DrawerPopupElementthat reads base-ui'sswipingstate and dispatches apointercancelon 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:
pnpm check,tsc --noEmitpass;pnpm build:registryproduced no tracked changes.