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 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, () => {