fix(solid-virtual): preserve measurements on option updates#1203
Conversation
📝 WalkthroughWalkthroughIn ChangesPreserve measured sizes on reactive option update
🎯 2 (Simple) | ⏱️ ~10 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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.
Summary
measure()invalidation on reactive option updates with the normal virtualizer update lifecycleThis aligns Solid with the lifecycle used by the other adapters:
setOptions()during render and_willUpdate()after commitsetOptions(),_willUpdate(), thentriggerRef()setOptions(),_willUpdate(), then explicitly publishes its storesetOptions(),_willUpdate(), then explicitly publishes its virtual items and total sizeThe 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
countupdate 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 --runpnpm --filter @tanstack/solid-virtual test:typespnpm --filter @tanstack/solid-virtual test:eslintpnpm --filter @tanstack/solid-virtual build