Skip to content
Source
Sign inSign up
TanStack/table

fix(table-core): clear row value caches when column defs are replaced #6581

Openahmadelsayed97(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/6581/headopened

Showing 3 changed files with 114 additions and 0 deletions.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/stale-accessor-values.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/table-core': patch
+---
+​
+Clear row value caches when column definitions are replaced, so a column whose `accessorFn` changes no longer serves the value produced by the previous accessor.
31 additions and 0 deletionspackages/table-core/src/core/table/coreTablesFeature.utils.tsModified
View file
@@ -187,6 +187,34 @@
​
/**
+ * Clears every built row's accessor-value caches. Both are keyed by column id
+ * and rows outlive column-definition swaps, so a replaced `accessorFn` would
+ * otherwise never be read again. Emptied in place because sorted and grouped
+ * row clones share these objects by reference.
+ */
+function table_clearRowValueCaches<
+ TFeatures extends TableFeatures,
+ TData extends RowData,
+>(table: Table_Internal<TFeatures, TData>): void {
+ if (!table._rowModels.coreRowModel) {
+ return
+ }
+​