fix: finish drag when mouseup propagation stops - #1089
Conversation
|
@nrps9909 is attempting to deploy a commit to the afc163's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review. Walkthrough本次修改使 Changes拖拽释放事件修复
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized fix makes drag completion reliable when mouseup propagation is stopped and cleans up the listener consistently; no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant Slider
participant Document
participant Parent
Slider->>Document: 以捕获阶段注册 mouseup
Parent->>Document: 处理 mouseup 并停止冒泡
Document->>Slider: 触发拖拽释放处理
Slider->>Document: 移除 mouseup 监听器
Slider-->>Slider: 触发 onChangeComplete
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1089 +/- ##
=======================================
Coverage 98.66% 98.67%
=======================================
Files 15 15
Lines 751 752 +1
Branches 234 235 +1
=======================================
+ Hits 741 742 +1
Misses 10 10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Follow-up signed commit a536a73 covers the touchend-only preventDefault branch that Codecov identified. The regression starts a real touch drag, dispatches touchend, verifies the native default is prevented exactly once, and confirms onChangeComplete receives the unchanged range. Focused: 51 Range tests pass. Full coverage run: 123 tests and 5 snapshots pass; useDrag.ts now reports the new line covered. TypeScript and lint pass, and the touched files are Prettier-clean. |
Summary
mouseupin the capture phase;Background
Fixes #1024.
The drag listener was attached to
documentin the bubble phase. If any ancestor handledmouseupand calledstopPropagation(), the event never reached that listener. The slider therefore remained in its dragging transaction:onChangeCompletewas not called, the documentmousemovelistener stayed attached, and later pointer movement continued changing the value after release.Listening for the document-level end event in the capture phase lets the slider close its own drag transaction before an ancestor intentionally stops bubbling. The listener registration and both removal paths use the same capture flag.
Exact-base reproduction: the new regression left
onChangeCompleteat zero calls. With this patch it receives the final dragged value, and a subsequent document mousemove produces noonChangecall.Verification
npm test -- --runInBand: 5 suites, 120 tests, 5 snapshots passednpm run tsc: passednpm run lint: passednpm run compile: ESM, CJS, declarations, and CSS passedgit diff --check: passedAI assistance disclosure: Codex was used to trace event propagation and cleanup paths, audit duplicate PRs, draft the focused regression, and run the verification above. The final diff and results were reviewed locally before submission.
Summary by CodeRabbit