fix: alert modal bug fix (#22688)

This commit is contained in:
AAfghahi 2023-01-12 08:26:18 -05:00 committed by GitHub
parent cf00970cde
commit 5a422b31c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -194,18 +194,8 @@ const AsyncSelect = forwardRef(
[sortComparator, sortSelectedFirst], [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] = const [selectOptions, setSelectOptions] =
useState<SelectOptionsType>(initialOptionsSorted); useState<SelectOptionsType>(EMPTY_OPTIONS);
// add selected values to options list if they are not in it // add selected values to options list if they are not in it
const fullSelectOptions = useMemo(() => { const fullSelectOptions = useMemo(() => {
@ -441,8 +431,8 @@ const AsyncSelect = forwardRef(
// when `options` list is updated from component prop, reset states // when `options` list is updated from component prop, reset states
fetchedQueries.current.clear(); fetchedQueries.current.clear();
setAllValuesLoaded(false); setAllValuesLoaded(false);
setSelectOptions(initialOptions); setSelectOptions(EMPTY_OPTIONS);
}, [initialOptions]); }, [options]);
useEffect(() => { useEffect(() => {
setSelectValue(value); setSelectValue(value);