Repository navigation
Description
Describe the bug
On iOS WebKit, the scroll-anchoring path in @tanstack/virtual-core listens for touchstart and touchend on the scroll element, but not touchcancel. A touch can end with touchcancel instead of touchend (system gesture, interrupted scroll, an alert or overlay taking focus). When that happens, _iosTouching stays true, and size corrections / anchoring adjustments stay suppressed until the next full touch cycle.
Visible symptom: items that resize after a cancelled touch don't get their scroll position corrected, so content jumps.
Affected: iOS Safari and WKWebView, @tanstack/virtual-core 3.19.0 (also 3.17.x).
We've been running a local patch since 3.17.11 that registers touchcancel with the same handler as touchend and removes it in cleanup. Happy to open a PR with that one-listener change, a unit test, and a changeset.
Your minimal, reproducible example
fork the dynamic example on StackBlitz and paste the link. The fallback is your branch's test.
Steps to reproduce
- Open a virtualized list with dynamic item sizes on iOS Safari (real device or Simulator).
- Start a touch scroll, then interrupt it so WebKit fires
touchcancelinstead oftouchend(e.g. edge-swipe system gesture, or an alert/overlay taking focus mid-touch). - Let items above the viewport resize.
- Scroll anchoring no longer corrects the offset; visible content jumps.
virtualizer._iosTouchingstaystrueuntil the next full touch cycle.
Expected behavior
touchcancel should clear the iOS touch state the same way touchend does, so anchoring/size corrections resume immediately. Today only touchstart/touchend are listened to in the iOS anchoring path of @tanstack/virtual-core (3.19.0, also 3.17.x). Happy to open a PR adding touchcancel with the same handler, plus a unit test and changeset.
How often does this bug happen?
Every time
Screenshots or Videos
No response
Platform
- OS: iOS (also reproducible in iOS Simulator)
- Browser: Safari / WKWebView (WebKit)
- Version: iOS Safari 18+ (any WebKit that fires touchcancel)
tanstack-virtual version
v3.14.15 (@tanstack/react-virtual, which uses @tanstack/virtual-core v3.19.0)
TypeScript version
No response
Additional context
Fix is ready on a fork branch: https://github.com/mrosberghaus/virtual/tree/fix/ios-touchcancel (one listener + cleanup, unit test, patch changeset). Will open a PR referencing this issue.
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Activity