Skip to content

Commit

Permalink
close dropdown menus after selection
Browse files Browse the repository at this point in the history
  • Loading branch information
jarosenb committed Jun 17, 2024
1 parent 99ba743 commit 251be2d
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ export const DropdownSelect: React.FC<{
placeholder?: string;
onChange?: (value: DropdownValue[]) => void;
}> = ({ value, onChange, options, maxCount, placeholder }) => {
const [open, setOpen] = useState(false);
const handleChange = (newVal: { label?: string; value: string }[]) => {
const formValue = newVal.map((v) =>
v.label ? { id: v.value, name: v.label } : { id: 'other', name: v.value }
);

onChange && onChange(formValue);
setOpen(false);
};

const getValue = (
Expand All @@ -29,6 +31,8 @@ export const DropdownSelect: React.FC<{

return (
<Select
open={open}
onDropdownVisibleChange={(visible) => setOpen(visible)}
virtual={false}
placement="bottomLeft"
placeholder={placeholder}
Expand Down

0 comments on commit 251be2d

Please sign in to comment.