Skip to content

fix(svelte-virtual): preserve options when resubscribing - #1356

Merged
piecyk merged 1 commit into
TanStack:mainfrom
clean99:contrib/virtual-svelte-retain-options-on-resubscribe
Nov 1, 2026
Merged

piecyk merged 1 commit into
TanStack:mainfrom
clean99:contrib/virtual-svelte-retain-options-on-resubscribe

Conversation

@clean99

@clean99 clean99 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

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.

@changeset-bot

changeset-bot Bot commented Oct 31, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5ad1b3d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tanstack/svelte-virtual Patch

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

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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 51b06cd and 5ad1b3d.

Files selected for processing: 3
  • .changeset/quick-lists-return.md
  • packages/svelte-virtual/src/index.ts
  • packages/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.md
The mount callback applies empty partial options instead of initial options. The test verifies that the updated count and replacement onChange callback 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 to 5ad1b

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: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: preserving updated options when a Svelte virtualizer store is resubscribed.
Description check Passed The description includes the required Changes, Checklist, and Release Impact sections. It explains the motivation, testing, changeset, and linked issue.
Linked Issues check Passed Issue #1355 requires a Svelte virtualizer store to retain updated options after its last subscriber unsubscribes and a subscriber returns. In packages/svelte-virtual/src/index.ts, the mount callback…
Out of Scope Changes check Passed 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 Passed 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 #1355 requires a Svelte virtualizer store to retain updated options after its last subscriber unsubscribes and a subscriber returns. In packages/svelte-virtual/src/index.ts, the mount callback now calls setOptions({}), which resolves the current virtualizer.options and current onChange instead of replaying initialOptions. The added test covers both createVirtualizer and createWindowVirtualizer. 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.

Share

@nx-cloud

nx-cloud Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 5ad1b3d

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:36 UTC

@pkg-pr-new

pkg-pr-new Bot commented Nov 1, 2026

Copy link
Copy Markdown
More templates

@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@1356

commit: 5ad1b3d

@piecyk
piecyk merged commit 600204a into TanStack:main Nov 1, 2026
10 checks passed
@piecyk

piecyk commented Nov 1, 2026

Copy link
Copy Markdown
Collaborator

Thanks @clean99!

@github-actions github-actions Bot mentioned this pull request Nov 1, 2026
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.

Svelte virtualizer stores reset updated options when resubscribed

2 participants