Skip to content

perf(virtual-core): skip sync DOM reads during normal scrolling#1144

Merged
piecyk merged 1 commit intoTanStack:mainfrom
piecyk:perf/skip-sync-measure
Mar 12, 2026
Merged

perf(virtual-core): skip sync DOM reads during normal scrolling#1144
piecyk merged 1 commit intoTanStack:mainfrom
piecyk:perf/skip-sync-measure

Conversation

@piecyk
Copy link
Collaborator

@piecyk piecyk commented Mar 12, 2026

🎯 Changes

Inline _measureElement into measureElement and RO callback to simplify the measurement flow. During normal user scrolling, the ref callback (measureElement) now only registers the element with the ResizeObserver, the actual measurement is deferred to the async RO callback, avoiding layout thrashing from forced reflows.

Sync measurement in measureElement is gated behind scrollState, so it only runs during programmatic scrolling (scrollToIndex/scrollToOffset) where reconcileScroll needs sizes in the same frame to converge correctly.

✅ 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 Mar 12, 2026

⚠️ No Changeset found

Latest commit: a1f20f5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@nx-cloud
Copy link

nx-cloud bot commented Mar 12, 2026

View your CI Pipeline Execution ↗ for commit a1f20f5

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

☁️ Nx Cloud last updated this comment at 2026-03-12 18:48:59 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 12, 2026

More templates

@tanstack/angular-virtual

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

@tanstack/lit-virtual

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

@tanstack/react-virtual

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

@tanstack/solid-virtual

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

@tanstack/svelte-virtual

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

@tanstack/virtual-core

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

@tanstack/vue-virtual

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

commit: 9b64003

@piecyk piecyk force-pushed the perf/skip-sync-measure branch from dedc5bb to 10db36b Compare March 12, 2026 17:57
@piecyk piecyk force-pushed the perf/skip-sync-measure branch from 10db36b to a1f20f5 Compare March 12, 2026 18:47
@piecyk piecyk merged commit fc3c733 into TanStack:main Mar 12, 2026
4 checks passed
piecyk added a commit that referenced this pull request Mar 12, 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