fix(drag): wrap setPointerCapture in try/catch to handle InvalidPointerId#706
Open
EduardF1 wants to merge 2 commits into
Open
fix(drag): wrap setPointerCapture in try/catch to handle InvalidPointerId#706EduardF1 wants to merge 2 commits into
EduardF1 wants to merge 2 commits into
Conversation
…erId DragEngine.pointerDown called setPointerCapture unguarded, which throws a DOMException (InvalidPointerId) when the pointer id is no longer valid by the time the engine handles the event (e.g. the pointer was released between event dispatch and the capture call during rapid touch interactions). This aborted the drag gesture. Wrap the call in try/catch so the drag proceeds without pointer capture, mirroring the already-guarded releasePointerCapture in pointerUp. Adds a regression test. Fixes pmndrs#701 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🦋 Changeset detectedLatest commit: 38e5eb1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 38e5eb1:
|
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.
Problem
DragEngine.pointerDowncallssetPointerCaptureunguarded:Browsers throw a
DOMException: InvalidPointerIdwhen the pointer id is no longer valid by the time this runs — e.g. the pointer was released between event dispatch and the capture call during rapid touch interactions or certain browser quirks. The exception abortspointerDown, so the drag gesture never starts.The symmetric
releasePointerCapturecall inpointerUpis already wrapped in try/catch for exactly this reason — this PR adds the missing guard on the other side.Fix
Wrap
setPointerCapturein try/catch, consistent with the existingreleasePointerCapturehandling. The drag proceeds without pointer capture instead of throwing.Tests
Adds a regression test in
test/drag.test.tsxthat makessetPointerCapturethrowInvalidPointerIdand asserts the drag still starts (active/draggingtrue,onDragStartfired). Verified it fails onmainand passes with the fix.pnpm jest— 218 passed (8 suites), including the new testeslint packages/core/src/engines/DragEngine.ts— cleanIncludes a changeset (
@use-gesture/corepatch).Fixes #701