Skip to content
Source
Sign inSign up
TanStack/table

fix(svelte-table): keep controlled state from resetting after each change #6641

OpenNickSpag(GitHub profile, opens in a new tab)wants to merge 2 commits intomain fromrefs/pull/6641/headopened

Showing 5 changed files with 54 additions and 1 deletion (loading 2).

x
0 of 5 viewed, 5 left
5 additions and 0 deletions.changeset/raw-svelte-options-store.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/svelte-table': patch
+---
+​
+Fix controlled `expanded` and `pagination` state resetting straight after each change. The options store now uses `$state.raw`, so an options sync no longer wraps `data` in a new proxy, which the core row model treated as new data and answered by running its auto-resets.
7 additions and 1 deletionpackages/svelte-table/src/reactivity.svelte.tsModified
View file
@@ -31,8 +31,14 @@
return { unsubscribe }
​
+/**
+ * Backs the options store. Uses `$state.raw` because `set` always replaces the
+ * whole options object: a deep `$state` would wrap `options.data` in a new proxy
+ * on every set, which the row model treats as new data and resets controlled
+ * pagination/expanded state (#6640).
+ */
function createRuneWritableAtom<T>(initialValue: T): Atom<T> {
- let value = $state(initialValue)
+ let value = $state.raw(initialValue)
​
return {
set: (updater: T | ((prevVal: T) => T)) => {
42 additions and 0 deletionspackages/svelte-table/tests/fixtures/ExpandingHarness.svelteAdded
View file
@@ -0,0 +1,42 @@
+<script lang="ts">
+ import { createExpandedRowModel, stockFeatures } from '@tanstack/table-core'