Repository navigation
fix: make touchmove cancelable so touch scrolling does not scroll the page - #394
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: Medium Suggested reviewers: Merge Risk:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #394 +/- ##
=======================================
Coverage 97.89% 97.90%
=======================================
Files 20 20
Lines 902 906 +4
Branches 219 215 -4
=======================================
+ Hits 883 887 +4
Misses 19 19 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…omponent (#129) * fix(drawer): do not coerce empty string width or height to zero (react-component/drawer#631) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(pagination): add uz_Cyrl_UZ locale (react-component/pagination#730) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * feat(picker): add Uzbek Cyrillic (uz_Cyrl_UZ) locale (react-component/picker#1027) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * fix(virtual-list): make touchmove cancelable so touch scrolling does not scroll the page (react-component/virtual-list#394) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * chore(sync): advance color-picker, drawer, pagination, picker, virtual-list cursor to b8cf756a89, c5220e7155, 2728b339b2, 354232c516, 47882c1cf2 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: yanyubot <356405855+yanyubot@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Problem
Touch scrolling a virtual list logs this warning on every
touchmove, and the page scrolls together with the list:Cause
Browsers decide whether a touch sequence can be cancelled by checking for non-passive touch listeners when the touch begins. In
useMobileTouchMove, the list only has a passivetouchstartlistener at that point. The non-passivetouchmovelistener is added toe.targetinsideonTouchStart, after the check has already run. Everytouchmovethen arrives withcancelable: false, sopreventDefault()is ignored and the page's native scroll goes ahead.Fix
touchmovelistener with{ passive: false }on the list element, so the list area already counts as blocking when a touch begins. The real handler stays one.target: virtualized items can be unmounted mid-swipe, and events on a detached target never bubble up to the list. Nested lists still go through the existing_virtualHandledcheck.e.preventDefault()whene.cancelableis true. Moves can still be non-cancelable after a swipe passes the list's top or bottom edge and the page takes over the scroll (originScroll). Calling it there only logged the warning.CSS
touch-action: noneon the holder would also block native scrolling, but it can't be switched per move. It would stop the page from taking over at the list edges, whichoriginScrollrelies on.Tests
touchmovelistener before any touch starts.preventDefaultis not called on a non-cancelabletouchmove.touchmoveevents are now created withcancelable: true, like real ones.tscis clean.Closes #393
Summary by CodeRabbit