Skip to content
Source
Sign inSign up
TanStack/virtual

fix(solid-virtual): preserve measurements on option updates #1203

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

Summary

  • replace the Solid adapter's full measure() invalidation on reactive option updates with the normal virtualizer update lifecycle
  • publish virtual items and total size through Solid without clearing measured item sizes
  • add the Solid adapter's first library regression test

This aligns Solid with the lifecycle used by the other adapters:

  • React calls setOptions() during render and _willUpdate() after commit
  • Vue calls setOptions(), _willUpdate(), then triggerRef()
  • Svelte calls setOptions(), _willUpdate(), then explicitly publishes its store
  • Solid now calls setOptions(), _willUpdate(), then explicitly publishes its virtual items and total size

The framework publication mechanism differs, but reactive option updates no longer trigger a full measurement invalidation only in Solid.

OpenCode hit this while migrating its long desktop chat timeline from Virtua to TanStack Virtual. Streaming messages, prepended history, and asynchronously resizing tool output require retained visible rows to preserve their measurements; clearing them on a reactive count update caused temporary estimated geometry and visible movement.

The regression test measures a row at 100px, reactively increases count, and verifies the measurement and resulting total size remain intact.

Fixes #1197

Downstream context: https://github.com/anomalyco/opencode/pull/32331 Downstream patch: https://github.com/anomalyco/opencode/blob/refactor/tanstack-virtual-session/patches/%40tanstack%252Fsolid-virtual%403.13.28.patch

Verification

  • pnpm --filter @tanstack/solid-virtual test:lib --run
  • pnpm --filter @tanstack/solid-virtual test:types
  • pnpm --filter @tanstack/solid-virtual test:eslint
  • pnpm --filter @tanstack/solid-virtual build
  • Prettier check for changed files

Summary by CodeRabbit

  • Bug Fixes

    • Preserved measured virtualized item sizes when reactive virtualizer settings change.
    • Improved updates so virtualized item measurements and total size stay in sync after option changes.
  • Tests

    • Added coverage for reactive updates to confirm previously measured sizes are retained.
    1. Review Change Stack

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro

      Run ID: b93b3e32-99d2-4b7b-a685-06fe5b37a2e6

      📥 Commits

      Reviewing files that changed from the base of the PR and between 2346cc5de185e81a4ec71388b7c31f9b65dd31c0 and 3d8b455aec4d0886ab6bbf770e553f579c997c02.

      📒 Files selected for processing (1)
      • packages/solid-virtual/package.json
      ✅ Files skipped from review due to trivial changes (1)
      • packages/solid-virtual/package.json

      📝 Walkthrough

      Walkthrough

      createVirtualizerBase now refreshes Solid state with _willUpdate(), reconcile, and totalSize updates instead of calling measure(). The PR also adds a regression test, test scripts, and a patch changeset.

      Changes

      Preserve measured sizes on reactive option update

      Layer / File(s)Summary
      onChange handler fix + test wiring
      packages/solid-virtual/src/index.tsx, packages/solid-virtual/package.json, packages/solid-virtual/tests/index.test.ts
      Replaces virtualizer.measure() with instance._willUpdate(), setVirtualItems(reconcile(instance.getVirtualItems(), { key: 'index' })), and setTotalSize(instance.getTotalSize()) in the onChange handler. Adds test:lib and test:lib:dev npm scripts. A Vitest regression test verifies measured sizes persist after a reactive count update.
      Patch changeset
      .changeset/quiet-cats-preserve.md
      Adds a Changesets entry for @tanstack/solid-virtual at patch level, noting preserved measured item sizes on reactive option changes.

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

      Possibly related PRs

      • TanStack/virtual#1183 — Both changes preserve measured item sizes by avoiding forced re-measurement and reusing cached measurements.

      Suggested reviewers: piecyk

      🚥 Pre-merge checks | ✅ 3 | ❌ 2

      ❌ Failed checks (2 warnings)

      Check nameStatusExplanationResolution
      Description check⚠️ WarningThe description explains the change and verification, but it does not follow the required template sections.Add the required ## 🎯 Changes, ## ✅ Checklist, and ## 🚀 Release Impact sections, and fill in the checklist items.
      Docstring Coverage⚠️ WarningDocstring coverage is 0.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
      ✅ Passed checks (3 passed)
      Check nameStatusExplanation
      Title check✅ PassedThe title clearly summarizes the core fix: preserving measurements when Solid virtualizer options update.
      Linked Issues check✅ PassedThe changes match #1197 by replacing measure() invalidation with lifecycle updates and explicit Solid state publication.
      Out of Scope Changes check✅ PassedThe added test script and changeset support the fix and do not appear unrelated to the PR objective.
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      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.
    2. Pull request overview

      Note

      Copilot was unable to run its full agentic suite in this review.

      This PR updates the Solid Virtualizer integration to preserve previously measured item sizes when reactive virtualizer options (e.g., count) change, and adds coverage plus tooling to validate the behavior.

      Changes:

      • Replace the reactive-update path to avoid re-measuring in a way that drops cached item sizes.
      • Add a Vitest test verifying measured sizes persist across reactive option updates.
      • Add package scripts to run the library test suite and include a changeset for a patch release.

      Reviewed changes

      Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

      FileDescription
      packages/solid-virtual/src/index.tsxChanges update flow to preserve measured size cache across reactive option changes.
      packages/solid-virtual/tests/index.test.tsAdds a regression test for preserving measured sizes when reactive options change.
      packages/solid-virtual/package.jsonAdds Vitest scripts for running the new test suite.
      .changeset/quiet-cats-preserve.mdDocuments the patch-level behavior change for release notes.

      💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

      Resolvedby Hona(GitHub profile, opens in a new tab)
      Resolvedby Hona(GitHub profile, opens in a new tab)
      Resolvedby Hona(GitHub profile, opens in a new tab)
      Resolvedby Hona(GitHub profile, opens in a new tab)
    3. View your CI Pipeline Execution ↗ for commit 3d8b455aec4d0886ab6bbf770e553f579c997c02

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded16sView ↗
      nx run-many --target=build --exclude=examples/**✅ Succeeded19sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-07-01 07:31:44 UTC

    4. More templates

      @tanstack/angular-virtual

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

      @tanstack/lit-virtual

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

      @tanstack/marko-virtual

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

      @tanstack/react-virtual

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

      @tanstack/solid-virtual

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

      @tanstack/svelte-virtual

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

      @tanstack/virtual-core

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

      @tanstack/vue-virtual

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

      commit: 3d8b455

    5. piecyk merged this95ef53b

    6. piecyk closed this

Sign in to join this conversation.