fix(svelte-virtual): preserve options when resubscribing #1356
main fromrefs/pull/1356/head·merged by piecyk Changes#
resolves #1355
Resubscribing to a virtualizer store currently restores its initial count and callback. Keep the current options when restarting the subscription. The regression test checks the updated total size and that only the current callback runs.
pnpm run test:pr passes, including the Svelte tests, lint, types, build and publint.
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).
Summary by CodeRabbit#
- Bug Fixes
- Updated virtualizer settings now remain in effect when the Svelte store is resubscribed. Changes to item count and update callbacks are preserved, so measurements use the latest settings and no longer call a replaced callback.
- 1
No actionable comments were generated in the recent review.
Recent review info-
Run configuration-
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: defaults
- Review profile: CHILL
- Plan: Advanced
- Run ID:
eb4c6ad2-4799-4943-961c-7d8b2f22e8e3
Commits-
Reviewing files that changed from the base of the PR and between 51b06cd5e078a289fe1cbf25a8d2e647aa98bfff and 5ad1b3d0c62ca49ed10da85989e692196502fd3d.
Files selected for processing: 3-
.changeset/quick-lists-return.mdpackages/svelte-virtual/src/index.tspackages/svelte-virtual/tests/index.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
-
Walkthrough
-
The Svelte virtualizer store no longer reapplies its initial options when it mounts. A regression test checks that updated options persist after the last subscriber unsubscribes and the store is subscribed to again.
Changes: Svelte store option retention
Layer / File(s) Summary Mount behavior and regression test
packages/svelte-virtual/src/index.ts,packages/svelte-virtual/tests/index.test.ts,.changeset/quick-lists-return.mdThe mount callback applies empty partial options instead of initial options. The test verifies that the updated count and replacement onChangecallback remain in effect after resubscription. The changeset records a patch release.Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers:
yeungkc
Merge Risk:
Minimal · up to5ad1b-
The change preserves updated virtualizer options after resubscription, with regression coverage for size and callback behavior. It is ready to merge subject to normal checks.
Pre-merge checks:
5-
Check name Status Explanation Title check The title clearly and concisely describes the main change: preserving updated options when a Svelte virtualizer store is resubscribed. Description check The description includes the required Changes, Checklist, and Release Impact sections. It explains the motivation, testing, changeset, and linked issue. Linked Issues check Issue #1355requires a Svelte virtualizer store to retain updated options after its last subscriber unsubscribes and a subscriber returns. Inpackages/svelte-virtual/src/index.ts, the mount callback…Out of Scope Changes check The reviewed changes stay within issue #1355. The source change fixes option retention during store resubscription. The tests cover the regression and related callback behavior. The changeset document…Docstring Coverage No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Full details: Linked Issues check
-
Explanation
Issue
#1355requires a Svelte virtualizer store to retain updated options after its last subscriber unsubscribes and a subscriber returns. Inpackages/svelte-virtual/src/index.ts, the mount callback now callssetOptions({}), which resolves the currentvirtualizer.optionsand currentonChangeinstead of replayinginitialOptions. The added test covers bothcreateVirtualizerandcreateWindowVirtualizer. It verifies the updated count, total size, and replacement callback after resubscription. It also verifies that the old callback does not run and that the subscriber receives the update.
Full details: Out of Scope Changes check
-
Explanation
The reviewed changes stay within issue
#1355. The source change fixes option retention during store resubscription. The tests cover the regression and related callback behavior. The changeset documents the published Svelte package fix. No unrelated change is shown in the supplied change summary or reviewed files.
Full details: Docstring Coverage
-
Explanation
No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files. (1 skipped: 1 unsupported.)
-
Finishing Touches
-
Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
-
View your CI Pipeline Execution ↗ for commit 5ad1b3d0c62ca49ed10da85989e692196502fd3d
Command Status Duration Result nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded 18s View ↗ nx run-many --target=build --exclude=examples/**✅ Succeeded 22s View ↗
☁️ Nx Cloud last updated this comment at
2026-11-01 11:30:36UTCMore templates
- @tanstack/virtual-example-angular-chat
- @tanstack/virtual-example-angular-dynamic
- @tanstack/virtual-example-angular-fixed
- @tanstack/virtual-example-angular-infinite-scroll
- @tanstack/virtual-example-angular-padding
- @tanstack/virtual-example-angular-smooth-scroll
- @tanstack/virtual-example-angular-sticky
- @tanstack/virtual-example-angular-table
- @tanstack/virtual-example-angular-variable
- @tanstack/virtual-example-angular-window
- tanstack-lit-virtual-example-dynamic
- tanstack-lit-virtual-example-fixed
- tanstack-react-virtual-example-chat
- tanstack-react-virtual-example-dynamic
- tanstack-react-virtual-example-fixed
- tanstack-react-virtual-example-infinite-scroll
- tanstack-react-virtual-example-padding
- tanstack-react-virtual-example-pretext
- tanstack-react-virtual-example-scroll-padding
- tanstack-react-virtual-example-smooth-scroll
- tanstack-react-virtual-example-sticky
- tanstack-react-virtual-example-table
- tanstack-react-virtual-example-variable
- tanstack-react-virtual-example-window
- tanstack-marko-virtual-example-chat
- tanstack-marko-virtual-example-chat-pretext
- tanstack-marko-virtual-example-dynamic
- tanstack-marko-virtual-example-fixed
- tanstack-marko-virtual-example-grid
- tanstack-marko-virtual-example-infinite-scroll
- tanstack-marko-virtual-example-padding
- tanstack-marko-virtual-example-pretext
- tanstack-marko-virtual-example-scroll-padding
- tanstack-marko-virtual-example-smooth-scroll
- tanstack-marko-virtual-example-ssr
- tanstack-marko-virtual-example-ssr-fetch
- tanstack-marko-virtual-example-ssr-restore
- tanstack-marko-virtual-example-ssr-slice
- tanstack-marko-virtual-example-sticky
- tanstack-marko-virtual-example-table
- tanstack-marko-virtual-example-variable
- tanstack-marko-virtual-example-window
- tanstack-marko-virtual-example-window-ssr-slice
- tanstack-svelte-virtual-example-dynamic
- tanstack-svelte-virtual-example-fixed
- tanstack-svelte-virtual-example-infinite-scroll
- tanstack-svelte-virtual-example-smooth-scroll
- tanstack-svelte-virtual-example-sticky
- tanstack-svelte-virtual-example-table
- tanstack-vue-virtual-example-dynamic
- tanstack-vue-virtual-example-fixed
- tanstack-vue-virtual-example-infinite-scroll
- tanstack-vue-virtual-example-padding
- tanstack-vue-virtual-example-scroll-padding
- tanstack-vue-virtual-example-smooth-scroll
- tanstack-vue-virtual-example-sticky
- tanstack-vue-virtual-example-table
- tanstack-vue-virtual-example-variable
@tanstack/angular-virtual
npm i https://pkg.pr.new/@tanstack/angular-virtual@1356@tanstack/lit-virtual
npm i https://pkg.pr.new/@tanstack/lit-virtual@1356@tanstack/marko-virtual
npm i https://pkg.pr.new/@tanstack/marko-virtual@1356@tanstack/react-virtual
npm i https://pkg.pr.new/@tanstack/react-virtual@1356@tanstack/solid-virtual
npm i https://pkg.pr.new/@tanstack/solid-virtual@1356@tanstack/svelte-virtual
npm i https://pkg.pr.new/@tanstack/svelte-virtual@1356@tanstack/virtual-core
npm i https://pkg.pr.new/@tanstack/virtual-core@1356@tanstack/vue-virtual
npm i https://pkg.pr.new/@tanstack/vue-virtual@1356commit:
5ad1b3dpiecyk merged this600204a
piecyk closed this
Thanks @clean99!
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 5ad1b3d0c62ca49ed10da85989e692196502fd3d
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR