From 9051624486651081f52dc5d9291c0151f1f9210d Mon Sep 17 00:00:00 2001 From: Isaac Hunja Date: Wed, 11 Mar 2026 14:20:48 +0300 Subject: [PATCH 1/2] fix(svelte-virtual): force store update when setOptions is called When options like `count` change but the visible range stays the same, `onChange` is never called (it only fires on range changes). This means the Svelte store is not updated and the component does not re-render. Fix by calling `virtualizerWritable.set(virtualizer)` after _willUpdate() so the store always reflects the latest virtualizer state after any options change. This mirrors how vue-virtual uses `triggerRef(state)` after _willUpdate(). Fixes #969 --- packages/svelte-virtual/src/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/svelte-virtual/src/index.ts b/packages/svelte-virtual/src/index.ts index f16aa03ce..1607d8c2c 100644 --- a/packages/svelte-virtual/src/index.ts +++ b/packages/svelte-virtual/src/index.ts @@ -53,6 +53,11 @@ function createVirtualizerBase< }, }) virtualizer._willUpdate() + // Force store update in case the range didn't change (e.g. count increased + // but scroll position stayed the same). Without this, the store only + // updates when onChange fires (on range change), so changes like a new + // count that don't shift the visible range would not trigger a re-render. + virtualizerWritable.set(virtualizer) } virtualizerWritable = writable(virtualizer, () => { From cbdf62956a280d1021c2c540cba58c4801c63c81 Mon Sep 17 00:00:00 2001 From: Damian Pieczynski Date: Thu, 12 Mar 2026 19:31:14 +0100 Subject: [PATCH 2/2] Add changeset --- .changeset/proud-humans-burn.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/proud-humans-burn.md diff --git a/.changeset/proud-humans-burn.md b/.changeset/proud-humans-burn.md new file mode 100644 index 000000000..5f5f008fc --- /dev/null +++ b/.changeset/proud-humans-burn.md @@ -0,0 +1,5 @@ +--- +'@tanstack/svelte-virtual': patch +--- + +fix(svelte-virtual): force store update when setOptions is called