This is an automated email from the ASF dual-hosted git repository. kgabryje pushed a commit to branch what-if in repository https://gitbox.apache.org/repos/asf/superset.git
commit 48fca802dce2b1a6588fc7f1ae20161fd74b4e32 Author: Kamil Gabryjelski <[email protected]> AuthorDate: Tue Dec 16 18:11:53 2025 +0100 FIX TABLE RERENDER --- .../components/gridComponents/Chart/Chart.jsx | 19 ++++++---------- .../src/dashboard/util/charts/getOwnDataCharts.ts | 25 +++++++++++++++++++--- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/superset-frontend/src/dashboard/components/gridComponents/Chart/Chart.jsx b/superset-frontend/src/dashboard/components/gridComponents/Chart/Chart.jsx index 341f27b0de..931ea28d40 100644 --- a/superset-frontend/src/dashboard/components/gridComponents/Chart/Chart.jsx +++ b/superset-frontend/src/dashboard/components/gridComponents/Chart/Chart.jsx @@ -415,9 +415,13 @@ const Chart = props => { const ownState = useMemo(() => { const baseOwnState = dataMask[props.id]?.ownState || EMPTY_OBJECT; + // Create a chartState-like object that includes state from chartState or formData fallbacks + const chartStateForConversion = { + state: getChartStateWithFallback(chartState, formData, slice.viz_type), + }; return createOwnStateWithChartState( baseOwnState, - chartState, + chartStateForConversion, slice.viz_type, ); }, [ @@ -425,6 +429,7 @@ const Chart = props => { props.id, slice.viz_type, chartState?.state, + formData, ]); const onExploreChart = useCallback( @@ -698,17 +703,7 @@ const Chart = props => { formData={formData} labelsColor={labelsColor} labelsColorMap={labelsColorMap} - ownState={createOwnStateWithChartState( - dataMask[props.id]?.ownState || EMPTY_OBJECT, - { - state: getChartStateWithFallback( - chartState, - formData, - slice.viz_type, - ), - }, - slice.viz_type, - )} + ownState={ownState} filterState={dataMask[props.id]?.filterState} queriesResponse={chart.queriesResponse} timeout={timeout} diff --git a/superset-frontend/src/dashboard/util/charts/getOwnDataCharts.ts b/superset-frontend/src/dashboard/util/charts/getOwnDataCharts.ts index 813917af59..5342cd8bf7 100644 --- a/superset-frontend/src/dashboard/util/charts/getOwnDataCharts.ts +++ b/superset-frontend/src/dashboard/util/charts/getOwnDataCharts.ts @@ -24,6 +24,24 @@ export const arrayDiff = (a: string[], b: string[]) => [ ...b.filter(x => !a.includes(x)), ]; +// Fields in ownState that don't require re-querying the chart when changed +// clientView is used by TableChart to store filtered rows for export - it's a +// derived/cached value that doesn't affect the query +const IGNORED_OWN_STATE_FIELDS = ['clientView']; + +const getComparableOwnState = ( + ownState: JsonObject | undefined, +): JsonObject => { + if (!ownState) return {}; + const result: JsonObject = {}; + Object.keys(ownState).forEach(key => { + if (!IGNORED_OWN_STATE_FIELDS.includes(key)) { + result[key] = ownState[key]; + } + }); + return result; +}; + export const getAffectedOwnDataCharts = ( ownDataCharts: JsonObject, appliedOwnDataCharts: JsonObject, @@ -35,9 +53,10 @@ export const getAffectedOwnDataCharts = ( ); const checkForUpdateIds = new Set<string>([...chartIds, ...appliedChartIds]); checkForUpdateIds.forEach(chartId => { - if ( - !areObjectsEqual(ownDataCharts[chartId], appliedOwnDataCharts[chartId]) - ) { + // Compare ownState excluding fields that don't require re-querying + const currentState = getComparableOwnState(ownDataCharts[chartId]); + const appliedState = getComparableOwnState(appliedOwnDataCharts[chartId]); + if (!areObjectsEqual(currentState, appliedState)) { affectedIds.push(chartId); } });
