fix(dashboard): restore filterState prop for cross-filter functionality (#38349)

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Evan Rusackas
2026-03-04 14:05:21 -05:00
committed by GitHub
parent 3d5694ee0f
commit 3b656f9cc2
3 changed files with 33 additions and 0 deletions

View File

@@ -26,6 +26,7 @@ import {
SqlaFormData,
ClientErrorObject,
DataRecordFilters,
type FilterState,
type JsonObject,
type AgGridChartState,
} from '@superset-ui/core';
@@ -89,6 +90,7 @@ export interface ChartProps {
onChartStateChange?: (chartState: AgGridChartState) => void;
/** Whether to suppress the loading spinner (during auto-refresh) */
suppressLoadingSpinner?: boolean;
filterState?: FilterState;
}
export type Actions = {

View File

@@ -29,6 +29,15 @@ import chartQueries, {
} from 'spec/fixtures/mockChartQueries';
import Chart from './Chart';
let capturedChartContainerProps: Record<string, unknown> = {};
jest.mock('src/components/Chart/ChartContainer', () => {
const MockChartContainer = (props: Record<string, unknown>) => {
capturedChartContainerProps = props;
return <div data-test="chart-container" />;
};
return { __esModule: true, default: MockChartContainer };
});
const props = {
id: queryId,
width: 100,
@@ -452,3 +461,24 @@ test('should merge base ownState with converted chart state', () => {
expect(getByTestId('chart-container')).toBeInTheDocument();
});
test('should pass filterState from dataMask to ChartContainer', () => {
const mockFilterState = { value: ['bar'], selectedValues: ['bar'] };
setup(
{},
{
...defaultState,
dataMask: {
[queryId]: {
filterState: mockFilterState,
},
},
},
);
expect(capturedChartContainerProps).toHaveProperty(
'filterState',
mockFilterState,
);
});

View File

@@ -761,6 +761,7 @@ const Chart = (props: ChartProps) => {
emitCrossFilters={emitCrossFilters}
onChartStateChange={handleChartStateChange}
suppressLoadingSpinner={suppressLoadingSpinner}
filterState={dataMask[props.id]?.filterState}
/>
</ChartWrapper>