Skip to content
Source
Sign inSign up
TanStack/virtual

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

Mergedclean99(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/1356/headmerged 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. 🦋 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
      NameType
      @tanstack/svelte-virtualPatch

      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

    2. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      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 51b06cd5e078a289fe1cbf25a8d2e647aa98bfff and 5ad1b3d0c62ca49ed10da85989e692196502fd3d.

      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 nameStatusExplanation
      Title checkPassedThe title clearly and concisely describes the main change: preserving updated options when a Svelte virtualizer store is resubscribed.
      Description checkPassedThe description includes the required Changes, Checklist, and Release Impact sections. It explains the motivation, testing, changeset, and linked issue.
      Linked Issues checkPassedIssue #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 checkPassedThe 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 CoveragePassedNo 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
    3. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 5ad1b3d0c62ca49ed10da85989e692196502fd3d

      CommandStatusDurationResult
      nx affected --targets=test:sherif,test:knip,tes...✅ Succeeded18sView ↗
      nx run-many --target=build --exclude=examples/**✅ Succeeded22sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-11-01 11:30:36 UTC

    4. 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

    5. piecyk merged this600204a

    6. piecyk closed this

    7. Thanks @clean99!

Sign in to join this conversation.