Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
Fix issue where multi select could be selected more than once
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Aug 13, 2020
1 parent 60b9f17 commit 83b04f7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/bumbag/src/SelectMenu/SelectMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ const useProps = createHook<SelectMenuProps>(
({ option }) => () => {
if (isMultiSelect) {
let newOptions = [];
if (selectedOptions.includes(option)) {
if (selectedOptions.some((selectedOption) => selectedOption.key === option.key)) {
newOptions = selectedOptions.filter((selectedOption) => option.key !== selectedOption.key);
} else {
newOptions = [...selectedOptions, option];
Expand All @@ -318,10 +318,9 @@ const useProps = createHook<SelectMenuProps>(
newOptions = '';
}
onChange && onChange(newOptions, newOptions);
dropdownMenu.hide();
}
},
[disableClear, dropdownMenu, isMultiSelect, onChange, selectedOptions]
[disableClear, isMultiSelect, onChange, selectedOptions]
);

const handleClickButton = React.useCallback(() => {
Expand Down Expand Up @@ -493,6 +492,7 @@ const useProps = createHook<SelectMenuProps>(
iconAfterProps={option.iconAfterProps}
iconBefore={option.iconBefore}
iconBeforeProps={option.iconBeforeProps}
hideOnClick={!isMultiSelect}
onClick={handleClickItem({ index, option })}
overrides={overrides}
{...itemProps}
Expand Down

0 comments on commit 83b04f7

Please sign in to comment.