Skip to content

Comments

fix(virtual-core): prevent scrollToIndex crash on unmount#1130

Closed
piecyk wants to merge 2 commits intoTanStack:mainfrom
piecyk:fix/scroll-to-index-unmounted
Closed

fix(virtual-core): prevent scrollToIndex crash on unmount#1130
piecyk wants to merge 2 commits intoTanStack:mainfrom
piecyk:fix/scroll-to-index-unmounted

Conversation

@piecyk
Copy link
Collaborator

@piecyk piecyk commented Feb 23, 2026

🎯 Changes

Guard scrollToIndex so that scheduled scroll work becomes a no-op when the scroll container is no longer available (e.g. component unmounted).
Previously, scroll work scheduled via requestAnimationFrame could throw if the scroll element was removed before execution.

This aligns the behavior with expectations for an imperative helper: if there’s no scroll container, do nothing rather than crash.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

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

@changeset-bot
Copy link

changeset-bot bot commented Feb 23, 2026

🦋 Changeset detected

Latest commit: 3c44034

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

This PR includes changesets to release 7 packages
Name Type
@tanstack/virtual-core Patch
@tanstack/angular-virtual Patch
@tanstack/lit-virtual Patch
@tanstack/react-virtual Patch
@tanstack/solid-virtual Patch
@tanstack/svelte-virtual Patch
@tanstack/vue-virtual Patch

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

@nx-cloud
Copy link

nx-cloud bot commented Feb 23, 2026

View your CI Pipeline Execution ↗ for commit 3c44034

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 2m 15s View ↗
nx run-many --target=build --exclude=examples/** ✅ Succeeded 16s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-23 17:06:24 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 23, 2026

More templates

@tanstack/angular-virtual

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

@tanstack/lit-virtual

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

@tanstack/react-virtual

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

@tanstack/solid-virtual

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

@tanstack/svelte-virtual

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

@tanstack/virtual-core

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

@tanstack/vue-virtual

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

commit: 3c44034

@piecyk
Copy link
Collaborator Author

piecyk commented Feb 23, 2026

Closing this PR since the changes will be addressed in #1129

@piecyk piecyk closed this Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant