From 449cfe299b1bd2eaf15a42cee366158a3b2e03fa Mon Sep 17 00:00:00 2001 From: Kamil Gabryjelski Date: Tue, 7 Mar 2023 14:07:59 +0100 Subject: [PATCH] fix(dashboard): Infinite load when filter with default first value is out of scope --- .../FilterBar/FilterControls/FilterControls.tsx | 7 +++++++ .../FilterBar/FiltersDropdownContent/index.tsx | 3 +++ .../FilterBar/FiltersOutOfScopeCollapsible/index.tsx | 3 +++ 3 files changed, 13 insertions(+) diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.tsx index d4ec83c1e2abd..589e7609e852a 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterControls.tsx @@ -124,6 +124,11 @@ const FilterControls: FC = ({ const [filtersInScope, filtersOutOfScope] = useSelectFiltersInScope(filtersWithValues); + const hasRequiredFirst = useMemo( + () => filtersWithValues.some(filter => filter.requiredFirst), + [filtersWithValues], + ); + const dashboardHasTabs = useDashboardHasTabs(); const showCollapsePanel = dashboardHasTabs && filtersWithValues.length > 0; @@ -149,6 +154,7 @@ const FilterControls: FC = ({ {showCollapsePanel && ( 0} renderer={renderer} /> @@ -264,6 +270,7 @@ const FilterControls: FC = ({ renderer={renderer} rendererCrossFilter={rendererCrossFilter} showCollapsePanel={showCollapsePanel} + forceRenderOutOfScope={hasRequiredFirst} /> ) : undefined diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FiltersDropdownContent/index.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FiltersDropdownContent/index.tsx index c4c720710bbd8..39d9816d47aaa 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FiltersDropdownContent/index.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FiltersDropdownContent/index.tsx @@ -34,6 +34,7 @@ export interface FiltersDropdownContentProps { last: CrossFilterIndicator, ) => ReactNode; showCollapsePanel?: boolean; + forceRenderOutOfScope?: boolean; } export const FiltersDropdownContent = ({ @@ -43,6 +44,7 @@ export const FiltersDropdownContent = ({ renderer, rendererCrossFilter, showCollapsePanel, + forceRenderOutOfScope, }: FiltersDropdownContentProps) => (
@@ -64,6 +66,7 @@ export const FiltersDropdownContent = ({ )} diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FiltersOutOfScopeCollapsible/index.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FiltersOutOfScopeCollapsible/index.tsx index 898ca2768e253..d63ae2179f288 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FiltersOutOfScopeCollapsible/index.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FiltersOutOfScopeCollapsible/index.tsx @@ -26,6 +26,7 @@ export interface FiltersOutOfScopeCollapsibleProps { renderer: (filter: Filter | Divider, index: number) => ReactNode; hasTopMargin?: boolean; horizontalOverflow?: boolean; + forceRender?: boolean; } export const FiltersOutOfScopeCollapsible = ({ @@ -33,6 +34,7 @@ export const FiltersOutOfScopeCollapsible = ({ renderer, hasTopMargin, horizontalOverflow, + forceRender = false, }: FiltersOutOfScopeCollapsibleProps) => ( css`