You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: preserve pointer data when cancelling a drag - #831
Returning false from onDrag creates a mouse-up event at (0, 0). For mouse drags, onStop therefore receives the wrong coordinates; for touch drags, the event has no matching touch identifier, so dragging never stops and subsequent moves still trigger callbacks.
Pass the original move event to handleDragStop so it retains the pointer coordinates and touch identifier. This also removes the synthetic-event fallback. Two regressions failed before the fix; all 206 unit tests and 23 Chromium browser tests now pass. ESLint, source/public types (React 18 and 19), CJS/ESM/declaration/UMD builds, and the build-contract checks pass.
Related to #486. Other browsers and the full Node-version matrix were not run.
Summary by CodeRabbit
Bug Fixes
Improved drag cancellation handling so the final position and movement changes are preserved when a drag ends unexpectedly.
Prevented additional movement notifications after a touch drag is canceled.
Prevented duplicate drag-stop notifications during cancellation or component removal.
Tests
Added coverage for mouse and touch drag cancellation scenarios, including final coordinates, movement changes, and callback behavior.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Advanced
Run ID: be89e1e1-7364-4faf-a115-e23e2ac667c0
📥 Commits
Reviewing files that changed from the base of the PR and between 40829e3 and a4a6ea4.
📒 Files selected for processing: 2
lib/DraggableCore.tsx
test/DraggableCore.test.jsx
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
📝 Walkthrough
When a drag ends because onDrag returns false, handleDrag now passes the original event to handleDragStop. New tests cover mouse cancellation data and touch cancellation callbacks.
Changes: Drag cancellation
Layer / File(s)
Summary
Stop event and cancellation tests lib/DraggableCore.tsx, test/DraggableCore.test.jsx
handleDrag passes the original event to handleDragStop on cancellation. Tests verify that mouse cancellation preserves coordinates and deltas, and that touch cancellation suppresses later movement callbacks and duplicate stop callbacks.
Cancelling a drag now preserves the real pointer coordinates and touch identifier, so onStop receives correct data. No actionable merge risk remains.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main change: preserving pointer data when a drag is cancelled.
Docstring Coverage
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.
✨ Finishing Touches
🧪 Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
🔧 ESLint
If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.
lib/DraggableCore.tsx
ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.
test/DraggableCore.test.jsx
ESLint skipped: the matched ESLint configuration already failed (missing-dependency).
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.
Comment @coderabbitai help to get the list of available commands.
This branch has not been deployed
No deployments
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
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.
Returning
falsefromonDragcreates a mouse-up event at (0, 0). For mouse drags,onStoptherefore receives the wrong coordinates; for touch drags, the event has no matching touch identifier, so dragging never stops and subsequent moves still trigger callbacks.Pass the original move event to
handleDragStopso it retains the pointer coordinates and touch identifier. This also removes the synthetic-event fallback. Two regressions failed before the fix; all 206 unit tests and 23 Chromium browser tests now pass. ESLint, source/public types (React 18 and 19), CJS/ESM/declaration/UMD builds, and the build-contract checks pass.Related to #486. Other browsers and the full Node-version matrix were not run.
Summary by CodeRabbit
Bug Fixes
Tests