be sure to only select one if type is not multi (#20410)

fixes: #20304
This commit is contained in:
Erik Jan de Wit 2023-05-25 13:01:30 +02:00 committed by GitHub
parent 1b8901f5a2
commit 8a6790be1d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -137,10 +137,17 @@ export const ResourcesPolicySelect = ({
selections={field.value}
onSelect={(_, selectedValue) => {
const option = selectedValue.toString();
const changedValue = field.value?.find((p: string) => p === option)
? field.value.filter((p: string) => p !== option)
: [...field.value!, option];
field.onChange(changedValue);
if (variant === SelectVariant.typeaheadMulti) {
const changedValue = field.value?.find(
(p: string) => p === option
)
? field.value.filter((p: string) => p !== option)
: [...field.value!, option];
field.onChange(changedValue);
} else {
field.onChange([option]);
}
setSearch("");
}}
isOpen={open}