fix(solid-virtual): preserve measurements on option updates by Hona · Pull Request #1203 · TanStack/virtual · GitHub
Skip to content

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

Merged
piecyk merged 2 commits into
TanStack:mainfrom
Hona:fix/solid-preserve-measurements
Jul 2, 2026
Merged

piecyk merged 2 commits into
TanStack:mainfrom
Hona:fix/solid-preserve-measurements

Conversation

@Hona

@Hona Hona commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

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

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

@piecyk
piecyk merged commit 95ef53b into TanStack:main Jul 2, 2026
10 checks passed
@github-actions github-actions Bot mentioned this pull request Jul 2, 2026
@piecyk piecyk mentioned this pull request Jul 2, 2026
4 tasks
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