mirror of
https://github.com/apache/superset.git
synced 2026-05-07 08:54:23 +00:00
FIX TABLE RERENDER
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user