Skip to content

Commit

Permalink
fix: collapse issue
Browse files Browse the repository at this point in the history
  • Loading branch information
SySagar committed Feb 4, 2024
1 parent 845a738 commit ab56c61
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/fuselage/src/components/MultiSelect/MultiSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ export const MultiSelect = forwardRef(
useEffect((): void => setInternalValue(value || []), [value]);

const [currentOptionValue, setCurrentOption] = useState<SelectOption[0]>();
const [visibleOptions, setVisibleOptions] = useState(
AnimatedVisibility.HIDDEN
);

const index = options.findIndex(
(option) => getValue(option) === currentOptionValue
Expand Down Expand Up @@ -108,7 +111,6 @@ export const MultiSelect = forwardRef(
}
return [value, label];
};

const applyFilter = ([, option]: SelectOption) =>
!filter || option.toLowerCase().includes(filter.toLowerCase());

Expand Down Expand Up @@ -142,10 +144,12 @@ export const MultiSelect = forwardRef(
};

const handleClick = useEffectEvent(() => {
if (visible === AnimatedVisibility.VISIBLE) {
if (visibleOptions === AnimatedVisibility.VISIBLE) {
setVisibleOptions(AnimatedVisibility.HIDDEN);
return hide();
}
innerRef.current?.focus();
setVisibleOptions(AnimatedVisibility.VISIBLE);
return show();
});

Expand Down

0 comments on commit ab56c61

Please sign in to comment.