From aec507d35c9deb7f36e7d83eb1eed3ce99bc4d2e Mon Sep 17 00:00:00 2001 From: "Michael S. Molina" <70410625+michael-s-molina@users.noreply.github.com> Date: Wed, 4 Aug 2021 11:52:39 -0300 Subject: [PATCH] fix: Fix the Select unselect for object values (#16062) (cherry picked from commit 1917464d2b357c98903ffbb7ba8b6e068c6102b8) --- superset-frontend/src/components/Select/Select.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/superset-frontend/src/components/Select/Select.tsx b/superset-frontend/src/components/Select/Select.tsx index 624571c8e51..fcdbdfc8cda 100644 --- a/superset-frontend/src/components/Select/Select.tsx +++ b/superset-frontend/src/components/Select/Select.tsx @@ -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(''); };