Skip to content

Commit 5ed73b8

Browse files
authored
fix(svelte-virtual): force store update when setOptions is called (#1143)
1 parent 54d771a commit 5ed73b8

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

.changeset/proud-humans-burn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/svelte-virtual': patch
3+
---
4+
5+
fix(svelte-virtual): force store update when setOptions is called

packages/svelte-virtual/src/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ function createVirtualizerBase<
5353
},
5454
})
5555
virtualizer._willUpdate()
56+
// Force store update in case the range didn't change (e.g. count increased
57+
// but scroll position stayed the same). Without this, the store only
58+
// updates when onChange fires (on range change), so changes like a new
59+
// count that don't shift the visible range would not trigger a re-render.
60+
virtualizerWritable.set(virtualizer)
5661
}
5762

5863
virtualizerWritable = writable(virtualizer, () => {

0 commit comments

Comments
 (0)