Repository navigation
fix: skip preventDefault on non-cancelable touch events in useDrag - #1101
Conversation
|
@Pareder 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. Walkthrough
Changes触摸事件处理
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Low Suggested reviewers: Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1101 +/- ##
=======================================
Coverage 98.69% 98.70%
=======================================
Files 15 15
Lines 769 770 +1
Branches 232 242 +10
=======================================
+ Hits 759 760 +1
Misses 10 10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…m rc-component (#135) * fix(virtual-list): skip preventDefault on non-cancelable scrollbar touchstart (react-component/virtual-list#396) * fix(tour): preserve zero-valued close icon overrides (react-component/tour#112) * fix(menu): preserve zero-valued item and expand icons (react-component/menu#897) * fix(input): preserve zero-valued suffix content (react-component/input#205) * fix(slider): skip preventDefault on non-cancelable touch events in useDrag (react-component/slider#1101) * fix(image): only preventDefault on cancelable touchmove events (react-component/image#539) * chore(sync): advance color-picker, image, input, menu, mutate-observer, rate, slider, tour and virtual-list cursors to upstream HEAD --------- Co-authored-by: yanyubot <356405855+yanyubot@users.noreply.github.com>
Closes #1100
Problem
useDragregisters its move/end handlers as the handle'stouchmoveandtouchendlisteners, and both callevent.preventDefault()unconditionally. If a drag starts while another finger is already scrolling the page, Chrome makes the rest of that touch sequence non-cancelable. It then logs this on every move and ontouchend:Fix
Only call
preventDefault()whenevent.cancelableis true, in both handlers. Single-finger drags are unchanged:touch-action: nonekeeps their events cancelable, so they are still prevented.Tests
touchmove/touchendnever callspreventDefault, andonChange/onChangeCompletestill fire with the right values. This test fails without the fix.touchmoveis still prevented.Summary by CodeRabbit