Skip to content
Source
Sign inSign up
TanStack/virtual

Svelte onChange stops firing after a partial setOptions update #1343

Closedclean99(GitHub profile, opens in a new tab) opened this issue 0 comments

Describe the bug

After calling setOptions({ count: 110 }), an existing onChange callback stops firing. The store still updates. This affects both createVirtualizer and createWindowVirtualizer.

Your minimal, reproducible example

https://github.com/clean99/virtual-svelte-onchange-repro (StackBlitz: https://stackblitz.com/github/clean99/virtual-svelte-onchange-repro)

Its reproduce.mjs needs only @tanstack/svelte-virtual@3.13.49 and svelte@4.2.20. Run npm install and npm start. It uses the public measure() method to trigger a state-change notification, without rendering a component or relying on browser timing.

Steps to reproduce

  1. Create a Svelte virtualizer with count: 100, estimateSize: () => 40, getScrollElement: () => null, and an onChange counter. Subscribe to its store.
  2. Call measure(): the counter becomes 1.
  3. Call setOptions({ count: 110 }), then measure() again.
  4. The counter stays at 1 instead of becoming 2. The reproduction asserts this for both exported constructors.

Expected behavior

An omitted option should remain unchanged in a partial update. The existing onChange callback should still fire when virtualizer state changes, as described in the API reference.

How often does this bug happen?

Every time.

Screenshots or Videos

Not applicable; the reproduction checks callback invocations directly.

Platform

macOS 26.5.2, Node.js 24.16.0. No browser is needed for this reproduction.

tanstack-virtual version

@tanstack/svelte-virtual 3.13.49, Svelte 4.2.20.

TypeScript version

The reproduction is JavaScript. The regression tests use TypeScript 5.9.3.

Additional context

The Svelte infinite-scroll example uses a count-only update after fetching another page. Adding an onChange callback to that pattern loses the callback after the update.

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct.
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
  1. piecyk closed this

Sign in to join this conversation.