From d9b15c3f4c267e93a2fd7db475eee058eb98f9e5 Mon Sep 17 00:00:00 2001 From: Evan Rusackas Date: Thu, 23 Apr 2026 02:32:30 -0700 Subject: [PATCH] address review: move sort cache clear to structural-deps effect --- .../src/react-pivottable/TableRenderers.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx index 4944392bf46..199cd6bb481 100644 --- a/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx +++ b/superset-frontend/plugins/plugin-chart-pivot-table/src/react-pivottable/TableRenderers.tsx @@ -754,14 +754,16 @@ export function TableRenderer({ ); // Compute base pivot settings, memoized based on relevant props - const basePivotSettings = useMemo(() => { - // Clear sort cache when props change - sortCacheRef.current.clear(); - return getBasePivotSettings(); - }, [getBasePivotSettings]); + const basePivotSettings = useMemo( + () => getBasePivotSettings(), + [getBasePivotSettings], + ); - // Reset sort state when structural props change + // Reset sort state and cache when structural props change. Scoping this to + // an effect (instead of running inside the memo) prevents the cache from + // being wiped on unrelated state updates like collapse/expand. useEffect(() => { + sortCacheRef.current.clear(); setSortingOrder([]); setActiveSortColumn(null); setSortedRowKeys(null);