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: Reordering native filters ignored by filter bar #22362

Merged
merged 3 commits into from
Dec 7, 2022
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 @@ -358,6 +358,7 @@ const DropdownContainer = forwardRef(
visible={popoverVisible}
onVisibleChange={visible => setPopoverVisible(visible)}
placement="bottom"
destroyTooltipOnHide
>
<Button
buttonStyle="secondary"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,15 @@ const FilterControls: FC<FilterControlsProps> = ({
const showCollapsePanel = dashboardHasTabs && filtersWithValues.length > 0;

const renderer = useCallback(
({ id }: Filter | Divider) => {
const index = filtersWithValues.findIndex(f => f.id === id);
({ id }: Filter | Divider, index: number | undefined) => {
const filterIndex = filtersWithValues.findIndex(f => f.id === id);
const key = index ?? id;
return (
// Empty text node is to ensure there's always an element preceding
// the OutPortal, otherwise react-reverse-portal crashes
<React.Fragment key={id}>
<React.Fragment key={key}>
{'' /* eslint-disable-line react/jsx-curly-brace-presence */}
<OutPortal node={portalNodes[index]} inView />
<OutPortal node={portalNodes[filterIndex]} inView />
</React.Fragment>
);
},
Expand All @@ -127,7 +128,7 @@ const FilterControls: FC<FilterControlsProps> = ({

const items = useMemo(
() =>
filtersInScope.map(filter => ({
filtersInScope.map((filter, index) => ({
id: filter.id,
element: (
<div
Expand All @@ -136,7 +137,7 @@ const FilterControls: FC<FilterControlsProps> = ({
flex-shrink: 0;
`}
>
{renderer(filter)}
{renderer(filter, index)}
</div>
),
})),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { FiltersOutOfScopeCollapsible } from '../FiltersOutOfScopeCollapsible';
export interface FiltersDropdownContentProps {
filtersInScope: (Filter | Divider)[];
filtersOutOfScope: (Filter | Divider)[];
renderer: (filter: Filter | Divider) => ReactNode;
renderer: (filter: Filter | Divider, index: number) => ReactNode;
showCollapsePanel?: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { AntdCollapse } from 'src/components';

export interface FiltersOutOfScopeCollapsibleProps {
filtersOutOfScope: (Filter | Divider)[];
renderer: (filter: Filter | Divider) => ReactNode;
renderer: (filter: Filter | Divider, index: number) => ReactNode;
hasTopMargin?: boolean;
horizontalOverflow?: boolean;
}
Expand Down