From 5a422b31c5d1ee3059c7659b376e3b8e1eeb257b Mon Sep 17 00:00:00 2001 From: AAfghahi <48933336+AAfghahi@users.noreply.github.com> Date: Thu, 12 Jan 2023 08:26:18 -0500 Subject: [PATCH] fix: alert modal bug fix (#22688) --- .../src/components/Select/AsyncSelect.tsx | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/superset-frontend/src/components/Select/AsyncSelect.tsx b/superset-frontend/src/components/Select/AsyncSelect.tsx index 5cbd193c56..4863095467 100644 --- a/superset-frontend/src/components/Select/AsyncSelect.tsx +++ b/superset-frontend/src/components/Select/AsyncSelect.tsx @@ -194,18 +194,8 @@ const AsyncSelect = forwardRef( [sortComparator, sortSelectedFirst], ); - const initialOptions = useMemo( - () => - options && Array.isArray(options) ? options.slice() : EMPTY_OPTIONS, - [options], - ); - const initialOptionsSorted = useMemo( - () => initialOptions.slice().sort(sortComparatorForNoSearch), - [initialOptions, sortComparatorForNoSearch], - ); - const [selectOptions, setSelectOptions] = - useState(initialOptionsSorted); + useState(EMPTY_OPTIONS); // add selected values to options list if they are not in it const fullSelectOptions = useMemo(() => { @@ -441,8 +431,8 @@ const AsyncSelect = forwardRef( // when `options` list is updated from component prop, reset states fetchedQueries.current.clear(); setAllValuesLoaded(false); - setSelectOptions(initialOptions); - }, [initialOptions]); + setSelectOptions(EMPTY_OPTIONS); + }, [options]); useEffect(() => { setSelectValue(value);