Skip to content

Commit

Permalink
🐛 Load filter values for multiselect before input (#1713)
Browse files Browse the repository at this point in the history
Resolves https://issues.redhat.com/browse/MTA-2322

- Need to load the select options into the dropdown state in cases where
category.selectOptions is async

---------

Signed-off-by: Ian Bolton <[email protected]>
  • Loading branch information
ibolton336 authored Feb 29, 2024
1 parent e9304fa commit d346801
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ export const MultiselectFilterControl = <TItem,>({
FilterSelectOptionProps[]
>(Array.isArray(category.selectOptions) ? category.selectOptions : []);

React.useEffect(() => {
setSelectOptions(
Array.isArray(category.selectOptions) ? category.selectOptions : []
);
}, [category.selectOptions]);

const hasGroupings = !Array.isArray(selectOptions);

const flatOptions: FilterSelectOptionProps[] = !hasGroupings
Expand Down

0 comments on commit d346801

Please sign in to comment.