fix: Fix the Select unselect for object values (#16062)

(cherry picked from commit 1917464d2b)
This commit is contained in:
Michael S. Molina
2021-08-04 11:52:39 -03:00
committed by Ville Brofeldt
parent 3c4f4dbf06
commit aec507d35c

View File

@@ -310,10 +310,13 @@ const Select = ({
const handleOnDeselect = (value: string | number | AntdLabeledValue) => {
if (Array.isArray(selectValue)) {
const selectedValues = [
...(selectValue as []).filter(opt => opt !== value),
];
setSelectValue(selectedValues);
if (typeof value === 'number' || typeof value === 'string') {
const array = selectValue as (string | number)[];
setSelectValue(array.filter(element => element !== value));
} else {
const array = selectValue as AntdLabeledValue[];
setSelectValue(array.filter(element => element.value !== value.value));
}
}
setSearchedValue('');
};