diff --git a/client/src/app/components/FilterToolbar/MultiselectFilterControl.tsx b/client/src/app/components/FilterToolbar/MultiselectFilterControl.tsx index 627faa55fc..271fb152e8 100644 --- a/client/src/app/components/FilterToolbar/MultiselectFilterControl.tsx +++ b/client/src/app/components/FilterToolbar/MultiselectFilterControl.tsx @@ -1,19 +1,23 @@ import * as React from "react"; -import { ToolbarChip, ToolbarFilter, Tooltip } from "@patternfly/react-core"; import { + Badge, + MenuToggle, + MenuToggleElement, Select, - SelectOption, - SelectOptionObject, - SelectVariant, - SelectProps, SelectGroup, -} from "@patternfly/react-core/deprecated"; + SelectOption, + SelectOptionProps, + ToolbarChip, + ToolbarFilter, + Tooltip, +} from "@patternfly/react-core"; import { IFilterControlProps } from "./FilterControl"; import { IMultiselectFilterCategory, FilterSelectOptionProps, } from "./FilterToolbar"; import { css } from "@patternfly/react-styles"; +import spacing from "@patternfly/react-styles/css/utilities/Spacing/spacing"; import "./select-overrides.css"; @@ -44,7 +48,7 @@ export const MultiselectFilterControl = ({ : Object.values(selectOptions).flatMap((i) => i); const getOptionKeyFromOptionValue = ( - optionValue: string | SelectOptionObject + optionValue: string | SelectOptionProps ) => flatOptions.find(({ value }) => value === optionValue)?.key; const getOptionKeyFromChip = (chip: string) => @@ -53,7 +57,7 @@ export const MultiselectFilterControl = ({ const getOptionValueFromOptionKey = (optionKey: string) => flatOptions.find(({ key }) => key === optionKey)?.value; - const onFilterSelect = (value: string | SelectOptionObject) => { + const onFilterSelect = (value: string | SelectOptionProps) => { const optionKey = getOptionKeyFromOptionValue(value); if (optionKey && filterValue?.includes(optionKey)) { const updatedValues = filterValue.filter( @@ -126,25 +130,58 @@ export const MultiselectFilterControl = ({ .filter(Boolean) : flatOptions .filter((o) => filter(o)) - .map((optionProps) => ( - - )); + .map((optionProps, index) => { + console.log("optionProps value", optionProps.value); + return ( + + {optionProps.value} + + ); + }); /** * Render options (with categories if available) where the option value OR key includes * the filterInput. */ - const onOptionsFilter: SelectProps["onFilter"] = (_event, textInput) => { - const input = textInput?.toLowerCase(); - - return renderSelectOptions((optionProps, groupName) => { - // TODO: Checking for a filter match against the key or the value may not be desirable. - return ( - groupName?.toLowerCase().includes(input) || - optionProps?.key?.toLowerCase().includes(input) || - optionProps?.value?.toString().toLowerCase().includes(input) - ); - }); + // const onOptionsFilter: SelectProps["onFilter"] = (_event, textInput) => { + // const input = textInput?.toLowerCase(); + + // return renderSelectOptions((optionProps, groupName) => { + // // TODO: Checking for a filter match against the key or the value may not be desirable. + // return ( + // groupName?.toLowerCase().includes(input) || + // optionProps?.key?.toLowerCase().includes(input) || + // optionProps?.value?.toString().toLowerCase().includes(input) + // ); + // }); + // }; + + const toggle = (toggleRef: React.Ref) => { + return ( + { + setIsFilterDropdownOpen(!isFilterDropdownOpen); + }} + isExpanded={isFilterDropdownOpen} + isDisabled={isDisabled || category.selectOptions.length === 0} + > + {category.placeholderText} + {filterValue?.length ? ( + + {filterValue?.length} + + ) : null} + + ); }; return ( @@ -158,16 +195,11 @@ export const MultiselectFilterControl = ({