Skip to content

Commit

Permalink
fix(dashboard): Infinite load when filter with default first value is…
Browse files Browse the repository at this point in the history
… out of scope (#23299)
  • Loading branch information
kgabryje authored and eschutho committed Mar 13, 2023
1 parent 224f962 commit 81a1318
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ const FilterControls: FC<FilterControlsProps> = ({
const [filtersInScope, filtersOutOfScope] =
useSelectFiltersInScope(filtersWithValues);

const hasRequiredFirst = useMemo(
() => filtersWithValues.some(filter => filter.requiredFirst),
[filtersWithValues],
);

const dashboardHasTabs = useDashboardHasTabs();
const showCollapsePanel = dashboardHasTabs && filtersWithValues.length > 0;

Expand All @@ -119,6 +124,7 @@ const FilterControls: FC<FilterControlsProps> = ({
{showCollapsePanel && (
<FiltersOutOfScopeCollapsible
filtersOutOfScope={filtersOutOfScope}
forceRender={hasRequiredFirst}
hasTopMargin={filtersInScope.length > 0}
renderer={renderer}
/>
Expand Down Expand Up @@ -200,6 +206,7 @@ const FilterControls: FC<FilterControlsProps> = ({
filtersOutOfScope={filtersOutOfScope}
renderer={renderer}
showCollapsePanel={showCollapsePanel}
forceRenderOutOfScope={hasRequiredFirst}
/>
)
: undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ export interface FiltersDropdownContentProps {
filtersOutOfScope: (Filter | Divider)[];
renderer: (filter: Filter | Divider, index: number) => ReactNode;
showCollapsePanel?: boolean;
forceRenderOutOfScope?: boolean;
}

export const FiltersDropdownContent = ({
filtersInScope,
filtersOutOfScope,
renderer,
showCollapsePanel,
forceRenderOutOfScope,
}: FiltersDropdownContentProps) => (
<div
css={(theme: SupersetTheme) =>
Expand All @@ -47,6 +49,7 @@ export const FiltersDropdownContent = ({
<FiltersOutOfScopeCollapsible
filtersOutOfScope={filtersOutOfScope}
renderer={renderer}
forceRender={forceRenderOutOfScope}
horizontalOverflow
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ export interface FiltersOutOfScopeCollapsibleProps {
renderer: (filter: Filter | Divider, index: number) => ReactNode;
hasTopMargin?: boolean;
horizontalOverflow?: boolean;
forceRender?: boolean;
}

export const FiltersOutOfScopeCollapsible = ({
filtersOutOfScope,
renderer,
hasTopMargin,
horizontalOverflow,
forceRender = false,
}: FiltersOutOfScopeCollapsibleProps) => (
<AntdCollapse
ghost
Expand Down Expand Up @@ -80,6 +82,7 @@ export const FiltersOutOfScopeCollapsible = ({
}
>
<AntdCollapse.Panel
forceRender={forceRender}
header={t('Filters out of scope (%d)', filtersOutOfScope.length)}
key="1"
>
Expand Down

0 comments on commit 81a1318

Please sign in to comment.