Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dashboard): Infinite load when filter with default first value is out of scope #23299

Merged
merged 1 commit into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,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 @@ -149,6 +154,7 @@ const FilterControls: FC<FilterControlsProps> = ({
{showCollapsePanel && (
<FiltersOutOfScopeCollapsible
filtersOutOfScope={filtersOutOfScope}
forceRender={hasRequiredFirst}
hasTopMargin={filtersInScope.length > 0}
renderer={renderer}
/>
Expand Down Expand Up @@ -264,6 +270,7 @@ const FilterControls: FC<FilterControlsProps> = ({
renderer={renderer}
rendererCrossFilter={rendererCrossFilter}
showCollapsePanel={showCollapsePanel}
forceRenderOutOfScope={hasRequiredFirst}
/>
)
: undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface FiltersDropdownContentProps {
last: CrossFilterIndicator,
) => ReactNode;
showCollapsePanel?: boolean;
forceRenderOutOfScope?: boolean;
}

export const FiltersDropdownContent = ({
Expand All @@ -43,6 +44,7 @@ export const FiltersDropdownContent = ({
renderer,
rendererCrossFilter,
showCollapsePanel,
forceRenderOutOfScope,
}: FiltersDropdownContentProps) => (
<div
css={(theme: SupersetTheme) =>
Expand All @@ -64,6 +66,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={
<span
css={(theme: SupersetTheme) => css`
Expand Down