From 7768bf67b1f3f1a9ce2d2c8e3ed96d0d4ea1905f Mon Sep 17 00:00:00 2001 From: Radoslaw Szwajkowski Date: Fri, 13 Sep 2024 23:25:31 +0200 Subject: [PATCH] :bug: Fix closing filter chips created via SelectFilterControl (#2093) Resolves: https://github.com/konveyor/tackle2-ui/issues/2094 Signed-off-by: Radoslaw Szwajkowski --- .../app/components/FilterToolbar/SelectFilterControl.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client/src/app/components/FilterToolbar/SelectFilterControl.tsx b/client/src/app/components/FilterToolbar/SelectFilterControl.tsx index e33eb5083f..b1b6bf4183 100644 --- a/client/src/app/components/FilterToolbar/SelectFilterControl.tsx +++ b/client/src/app/components/FilterToolbar/SelectFilterControl.tsx @@ -5,6 +5,7 @@ import { Select, SelectList, SelectOption, + ToolbarChip, ToolbarFilter, } from "@patternfly/react-core"; import { IFilterControlProps } from "./FilterControl"; @@ -56,8 +57,9 @@ export const SelectFilterControl = ({ setIsFilterDropdownOpen(false); }; - const onFilterClear = (chip: string) => { - const newValue = filterValue?.filter((val) => val !== chip); + const onFilterClear = (chip: string | ToolbarChip) => { + const chipValue = typeof chip === "string" ? chip : chip.key; + const newValue = filterValue?.filter((val) => val !== chipValue); setFilterValue(newValue?.length ? newValue : null); }; @@ -90,7 +92,7 @@ export const SelectFilterControl = ({ onFilterClear(chip as string)} + deleteChip={(_, chip) => onFilterClear(chip)} categoryName={category.title} showToolbarItem={showToolbarItem} >