Skip to content
Source
Sign inSign up
TanStack/virtual

fix(virtual-core): treat iOS touchcancel like touchend so interrupted gestures cannot leave touch state stuck #1314

Mergedmrosberghaus(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/1314/headmerged by piecyk

🎯 Changes

On iOS WebKit a touch can end with touchcancel (system gesture, interrupted scroll) instead of touchend. The iOS scroll-anchoring path only listened for touchstart/touchend, so a cancelled touch left _iosTouching stuck true and kept size-correction / anchoring suppressed.

This registers touchcancel on scrollEl with the same onTouchEnd handler and options as touchend, and removes it in the existing cleanup. A unit test dispatches touchstart then touchcancel and asserts the touch state is cleared the same as touchend, and that cleanup drops the listener.

Fixes #1313

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally (@tanstack/virtual-core eslint, tsc, and vitest).

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes
    • Improved iOS touch handling so cancelled touches clear active touch state like ended touches, preventing scroll anchoring from remaining suppressed.
    • Touch event listeners are removed when the virtualizer unmounts.
    1. changeset-bot[bot](GitHub profile, opens in a new tab)commented

      🦋 Changeset detected

      Latest commit: dcc52ab52684c7d4b99cb057813ac71a3e8427c2

      The changes in this PR will be included in the next version bump.

      This PR includes changesets to release 9 packages
      NameType
      @tanstack/virtual-corePatch
      @tanstack/angular-virtualPatch
      @tanstack/lit-virtualPatch
      @tanstack/marko-virtualPatch
      @tanstack/react-virtualPatch
      @tanstack/solid-virtualPatch
      @tanstack/svelte-virtualPatch
      @tanstack/vue-virtualPatch
      @tanstack/virtual-benchmarksPatch

      Not sure what this means? Click here to learn what changesets are.

      Click here if you're a maintainer who wants to add another changeset to this PR

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: defaults
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: 41e2ca0b-5426-4992-8a0e-4957ee28cb3f

      📥 Commits

      Reviewing files that changed from the base of the PR and between 46f73fb419185536ee34ec1c6eba8ad8824d77b7 and dcc52ab52684c7d4b99cb057813ac71a3e8427c2.


      📒 Files selected for processing (3)
      • .changeset/ios-touchcancel-clears-touch.md
      • packages/virtual-core/src/index.ts
      • packages/virtual-core/tests/index.test.ts

      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

      Walkthrough

      The virtualizer now handles iOS touchcancel events with the existing touchend logic. Tests cover touch-state updates and listener cleanup. A patch changeset describes the change.

      Changes

      iOS touchcancel handling

      Layer / File(s)Summary
      Handle canceled touches and verify cleanup
      packages/virtual-core/src/index.ts, packages/virtual-core/tests/index.test.ts, .changeset/ios-touchcancel-clears-touch.md
      The virtualizer uses its existing touch-end handler for touchcancel and removes the listener during cleanup. Tests check touch state, grace-timer state, and listener cleanup. The changeset records the patch.

      Priority: ➖ Normal

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix · Severity of issue fixed: Medium

      Suggested reviewers: piecyk


      Merge Risk: ⚪ Minimal · up to dcc52

      The change restores touch state after canceled gestures and removes the listener during cleanup. No concrete merge-blocking risk remains.

      Pre-merge checks | Passed 4 | Failed 1

      ❌ Failed checks (1 warning)

      Check nameStatusExplanationResolution
      Docstring CoverageWarningDocstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1…Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Title checkPassedThe title clearly identifies the primary change: treating iOS touchcancel like touchend to prevent stuck touch state.
      Description checkPassedThe description explains the motivation, implementation, tests, linked issue, checklist completion, and changeset generation. It matches the repository template.
      Linked Issues checkPassedIssue #1313 requires touchcancel to clear iOS touch state like touchend, listener cleanup, an automated test, and a changeset. The PR registers onTouchEnd for touchcancel with the touchend o…
      Out of Scope Changes checkPassedThe reported changes are limited to the iOS touch-state implementation, its focused unit test, and the required @tanstack/virtual-core changeset. These changes directly support issue #1313. No unrel…

      Full details: Docstring Coverage

      Explanation

      Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. (1 skipped: 1 unsupported.)


      • Fix all pre-merge checks with AI
      ✨ 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.

      packages/virtual-core/tests/index.test.ts

      Parsing error: "parserOptions.project" has been provided for @typescript-eslint/parser. The file was not found in any of the provided project(s): packages/virtual-core/tests/index.test.ts



      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.

      ❤️ Share

      Comment `@coderabbitai help` to get the list of available commands.
    3. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit dcc52ab52684c7d4b99cb057813ac71a3e8427c2

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded4m 6sView ↗
      nx run-many --target=build --exclude=examples/**✅ Succeeded22sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-10-12 11:25:05 UTC

    4. More templates

      @tanstack/angular-virtual

      npm i https://pkg.pr.new/@tanstack/angular-virtual@1314

      @tanstack/lit-virtual

      npm i https://pkg.pr.new/@tanstack/lit-virtual@1314

      @tanstack/marko-virtual

      npm i https://pkg.pr.new/@tanstack/marko-virtual@1314

      @tanstack/react-virtual

      npm i https://pkg.pr.new/@tanstack/react-virtual@1314

      @tanstack/solid-virtual

      npm i https://pkg.pr.new/@tanstack/solid-virtual@1314

      @tanstack/svelte-virtual

      npm i https://pkg.pr.new/@tanstack/svelte-virtual@1314

      @tanstack/virtual-core

      npm i https://pkg.pr.new/@tanstack/virtual-core@1314

      @tanstack/vue-virtual

      npm i https://pkg.pr.new/@tanstack/vue-virtual@1314

      commit: dcc52ab

    5. @mrosberghaus thanks for the report and the clean fix!

    6. piecyk merged this3800fb3

    7. piecyk closed this

Sign in to join this conversation.