Skip to content

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

Open
Hona wants to merge 2 commits into
TanStack:mainfrom
Hona:fix/solid-preserve-measurements
Open

fix(solid-virtual): preserve measurements on option updates#1203
Hona wants to merge 2 commits into
TanStack:mainfrom
Hona:fix/solid-preserve-measurements

Conversation

@Hona

@Hona Hona commented Jun 16, 2026

Copy link
Copy Markdown

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: anomalyco/opencode#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.

Copilot AI review requested due to automatic review settings June 16, 2026 11:19
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

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 2346cc5 and 3d8b455.

📒 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 name Status Explanation Resolution
Description check ⚠️ Warning The 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 ⚠️ Warning Docstring 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 name Status Explanation
Title check ✅ Passed The title clearly summarizes the core fix: preserving measurements when Solid virtualizer options update.
Linked Issues check ✅ Passed The changes match #1197 by replacing measure() invalidation with lifecycle updates and explicit Solid state publication.
Out of Scope Changes check ✅ Passed The 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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

File Description
packages/solid-virtual/src/index.tsx Changes update flow to preserve measured size cache across reactive option changes.
packages/solid-virtual/tests/index.test.ts Adds a regression test for preserving measured sizes when reactive options change.
packages/solid-virtual/package.json Adds Vitest scripts for running the new test suite.
.changeset/quiet-cats-preserve.md Documents the patch-level behavior change for release notes.

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

Comment thread packages/solid-virtual/src/index.tsx
Comment thread packages/solid-virtual/package.json
Comment thread packages/solid-virtual/tests/index.test.ts
Comment thread packages/solid-virtual/tests/index.test.ts
@nx-cloud

nx-cloud Bot commented Jul 1, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 3d8b455

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

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

@pkg-pr-new

pkg-pr-new Bot commented Jul 1, 2026

Copy link
Copy Markdown
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

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.

solid-virtual: reactive option updates clear measured item sizes

3 participants