You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
svelte-table: controlled expanded and pagination state resets straight after every change #6640
svelte-table 9.3.1 (and table-core 9.3.1). First seen on 9.2.4.
Framework/Library version
svelte 5.57.0
Describe the bug and the steps to reproduce it
When expanded or pagination is controlled through state and on*Change, and with a plain array (constant/$derived value/TanStack Query result) for data, row.toggleExpanded() and table.nextPage() dont do anything. The table applies the change and then resets the slice to its initial value, on every click. With data held in $state the bug doesn't show, because Svelte keeps the existing proxy.
The Svelte adapter's options store is a deep $state (reactivity.svelte.ts#L35). On each options sync, the $effect.pre in createTable (createTable.svelte.ts#L87-L102) writes a new options object that holds the caller's raw data array, and $state wraps that array in a new proxy each time. So table.options.data gets a new identity on every sync, even though data itself hasn't changed. The core row model memoizes on table.options.data and runs the auto-resets whenever it recomputes (createCoreRowModel.ts#L31-L38). Changing a controlled slice re-runs the sync, so every change undoes itself.
#6374 is this bug for pagination. It was closed with autoResetPageIndex: false as the workaround; autoResetExpanded: false works the same way for expansion. Both also turn off the reset for genuine data changes. The same proxying means row.original is a Svelte proxy, not the object the caller passed in.
Do you intend to try to help solve this bug with your own PR?
Yes, I am also opening a PR that solves the problem along side this issue
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.
Activity