* refactor(table-core): centralize no-op state update guarding in setStateSlice
Route every table.setX state router through a single setStateSlice util
that resolves the updater once against the slice's current value,
structurally compares the result, and skips the onXChange handler
entirely when nothing changed. This removes the class of render loops
where auto resets fired change handlers with freshly allocated but
semantically identical values (e.g. autoResetExpanded after a data
reference change), and deletes the scattered ad-hoc guards that
previously protected individual slices.
For uncontrolled slices the default handler receives the pre-resolved
value, so updaters run exactly once. User handlers and externally owned
slices receive the original updater untouched to preserve functional
update composition and independent base-atom fallback semantics.
Supersedes #6519.
Co-Authored-By: Dmitrii Kartashev <dikartashev@gmail.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
* fix test and regen docs
* add date filters to filter examples
* omit row selection from new check
* auto fix lint issues
* ci: apply automated fixes
* format
* lint fix
* uncomment
* address stale updater bug, simplify
* still skip autoResetPageIndex in controlled state scenarios
* regen docs again
* refactor(table-core): make stateSlicesEqual the setStateSlice default, call unguarded handlers directly
setStateSlice now always guards, with isEqual as an override hook for
custom feature slices. Slices that deliberately skip guarding
(rowSelection, columnSizing, columnResizing, globalFilter, and the
expanded/cellSelection setters) call their change handler directly
instead of routing through a no-op wrapper, keeping pointer-frequency
paths free of the routing overhead. rowPinning picks up the guard via
the new default, matching columnPinning.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
---------
Co-authored-by: Dmitrii Kartashev <dikartashev@gmail.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Two independent clusters of default-behavior bugs from the beta triage.
Expanded and paginated state contents:
Expand-all materialized every id in `rowsById`, including leaf rows that
can never expand, so a serialized `ExpandedState` was polluted with dead
keys and `getExpandedDepth` was skewed by them. Materialization now writes
only ids where `row.getCanExpand()` is true, chosen over `subRows.length`
so `getRowCanExpand` lazy-load overrides stay expandable.
`getExpandedDepth` filters the same way, and `getIsAllRowsExpanded` now
only considers expandable rows so the materialized map still round-trips
as "all expanded" (a map of stale ids with no expandable rows is false).
Paginated `flatRows` pushed each row and then recursed into its subRows,
but page rows already contain expanded descendants inline, so those rows
appeared twice. The rebuild now dedupes by row id. Collapsed descendants
stay included, consistent with every other row model, where `flatRows`
ignores expansion state.
`row.toggleExpanded(bool)` and `table.toggleAllRowsExpanded(bool)` fired
`onExpandedChange` even when the requested state already matched, so
controlled consumers got spurious callbacks. Both now early-return.
Neither toggle consulted `row.getCanExpand()`, unlike their row-selection
equivalents, so a non-expandable row could be written into expanded state
imperatively. The expand direction is now guarded; collapsing is always
allowed so stale expanded ids can still be cleaned up.
Sorting toggle defaults:
`column.toggleSorting()` called `column.getNextSortingOrder(column)` with
no `multi` argument, so `enableMultiRemove` was dead on every path. The
argument is now forwarded as `multi && column.getCanMultiSort()`, matching
the multi-mode condition the updater itself uses. The public
`getNextSortingOrder` type now accepts the `multi` argument it always
supported at runtime.
`column.getAutoSortDir()` sampled only `flatRows[0]`, so a leading null or
a manual-sorting data swap flipped the inferred first direction mid-cycle
and silently dropped a state from the toggle cycle. It now samples the
first 10 rows for a non-nullish value, matching `getAutoSortFn`.
Docs: `sortUndefined: false` was documented as "considered tied" in all
framework sorting guides; undefined values are actually passed straight to
the sorting function with no special handling. Corrected, and the missing
`'first'`/`'last'` bullets were added to the generated reference.
Also fixes three crashes in the MRT examples surfaced while testing the
sorting changes. The MUI and Mantine sort labels read `sorting` off
`state`, which does not carry it, and crashed on `sorting.length`; they now
read it through `table.Subscribe` on `table.atoms.sorting`, which also
makes the badge reactive. The row-action edit handler passed a shallow row
copy to `setEditingRow`, breaking the row identity the edit modal needs.
`mrtRefsFeature` seeded the keyed `editInputRefs`/`filterInputRefs` bags
with `null` instead of `{}`, crashing on first keyed write. New e2e
coverage pins all three plus the sort-direction indicator.
Closes#6115Closes#5833Closes#6136Closes#4939Closes#4946Closes#5147Closes#5832
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
docs(table-core): correct getIsSome*Selected JSDoc to at-least-one semantics
`getIsSomeRowsSelected` and `getIsSomePageRowsSelected` were still documented
as "partial" selection checks, which is the v8 meaning. In v9 they return true
whenever at least one row is selected, including when all of them are.
`table_getIsSomeRowsSelected` also reads `state.rowSelection` rather than the
filtered row model, so "across filtered rows" was inaccurate as well.
The generated reference pages carry the same sentences, so they are updated
alongside the JSDoc.
Co-authored-by: Kevin Van Cott <kevinvandy656@gmail.com>
* perf: pre-compute instance init functions
When we construct a row, we iterate over the table's features and
initialise any which have an `initRowInstanceData`.
This is expensive since most don't have such a method.
We actually know when we construct the table which features have this
method. This changes the table construction to store the initialisers up
front so when we create a row, we can just iterate the already known
initialisers.
* fix(table-core): bind initialiser to feature
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
* cache init functions consistently for all table objects
---------
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Kevin Van Cott <kevinvandy656@gmail.com>
* fix: add back sub-rows onto aggregate context
* aggregate from sub-rows by default first like v8 behavior
* new APIs for custom aggregation depths
* fix example signatures
* update docs
* feat: batch row selection
* fix tests
* pr feedback and add migration guide note
* no more e2e in pr
* fix angular examples double building in ci tests
* fix type
* feat: update column pinning terminology from left/right to start/end
* update beta number
* update variable names and clarify left to right associations
* feat: implement fine-grained rerendering control with an async Lit directive
An async Lit directe `subscribe` is implemented to allow for fine-grained reactivity and rerendering of templates.
To support this, `@tanstack/lit-store` is integrated.
* fix package.json
* fix a ton of stuff
* regen docs
---------
Co-authored-by: Kevin Van Cott <kevinvandy656@gmail.com>
* feat: add angular devtools
* fix(table-devtools): fix table state reactivity
Refactor devtools panel with a more solid-idiomatic approach, using memo and dynamic `useTableState` subscription via Accessor getter to not break reactivity.
* Add devtools in all angular examples
* Use a stable identifier reference to register devtools in table
* Fix dependency versions
* ci: apply automated fixes
* generate instanceId for react-table
* fix basic external store examples
mark table.store as deprecated in adapter table types
replace table.store.state with table.state in examples
* add external atoms example in angular
* update package lock
* ci: apply automated fixes
* update angular adapter for readonly atom reactivity pattern
* add missing angular examples (WIP)
* clean up devtools on examples
* fix some angular reactivity
* ci: apply automated fixes
* fix solid and svelte reactivity issues
* update docs gen
* apply pr feedback
* make state reads consistent in angular examples
* ci: apply automated fixes
* fix infinite render in angular column-pinning-split
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Kevin Van Cott <kevinvandy656@gmail.com>
* fix: remove options store from react/preact and refactor external state subscriptions
* fix svelte reactivity issues
* sync state to baseAtoms in table construct
* update lock file
* feat: refactor table store into feature atoms
* get rid of stupid proxies because optional chaining isn't bad
* fix some legacy table stuff and update migrating guide
* subscribe with atoms refactor
* fixed vue table types
* fix more subscribe types
* simplify atom and store construction more