mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
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:
@@ -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 = {
|
||||
|
||||
@@ -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,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -761,6 +761,7 @@ const Chart = (props: ChartProps) => {
|
||||
emitCrossFilters={emitCrossFilters}
|
||||
onChartStateChange={handleChartStateChange}
|
||||
suppressLoadingSpinner={suppressLoadingSpinner}
|
||||
filterState={dataMask[props.id]?.filterState}
|
||||
/>
|
||||
</ChartWrapper>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user