Repository navigation
Conversation
…ange The options store was a deep `$state`, so every options sync wrapped the caller's `data` array in a new proxy. The core row model memoizes on `table.options.data`, saw new data, and ran its auto-resets, undoing the controlled `expanded` or `pagination` change that caused the sync. `set` always replaces the whole options object, so `$state.raw` gives the store all the reactivity it needs. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 15141a8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
🎯 Changes
Fixes #6640.
Bug cause reported in full in the accompanying #6640 issue. TLDR:
The Svelte adapter keeps the table's options in a deep $state. Every time the options are applied, Svelte wraps the plain data array in a new proxy, so table.options.data is a different object each time even though the data hasn't changed. The core row model treats that as new data and runs its auto-resets. Changing controlled expanded or pagination applies the options again, so each change is immediately reset back. When data is already in $state, Svelte reuses the existing proxy and the bug doesn't show.
Fix:
$state.raw.setalways replaces the whole options object, so a top-level signal is all the store needs. As a side effect,row.originalis the caller's object again rather than a proxy of it.Tests:
PaginationHarnessgains a "Next page" button, and a newExpandingHarnesscontrolsexpandedwithcreateTableState. The existing pagination test only callssetPageSize(3), which ends on page 0 whether or not the reset fires, so it didn't catch this. Both new tests fail before the change and pass after it.The examples don't show the bug because they all keep
datain$state. Svelte leaves an existing proxy as it is, sotable.options.datastays stable there. The bug needs a plain array (a constant, a$derivedvalue, or a TanStack Query result), which is why the new tests use the fixtures' plain arrays. The TanStack Query example avoids it for a different reason: it setsmanualPagination: true, which turns off the page reset.✅ Checklist
pnpm testandpnpm test:e2e, or these tests do not apply to this pull request.Locally: the
@tanstack/svelte-tabletargets frompnpm test(test:lib,test:types,test:eslint,build,test:build) all pass.test:e2epasses for all 41 Svelte examples (164 tests). The two new unit tests fail without the change and pass with it.🚀 Release Impact
Summary by CodeRabbit