From e1d788548125169f996e824f95943b7479e04d9c Mon Sep 17 00:00:00 2001 From: Sven van de Scheur Date: Thu, 27 Jun 2024 14:20:17 +0200 Subject: [PATCH] :bug: - fix: fix a bug that could cause a select not to be cleared correctly --- src/components/form/form/form.tsx | 4 ++-- src/components/form/select/select.tsx | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/components/form/form/form.tsx b/src/components/form/form/form.tsx index cc108a9c..39e39d28 100644 --- a/src/components/form/form/form.tsx +++ b/src/components/form/form/form.tsx @@ -118,11 +118,11 @@ export const Form: React.FC = ({ const [errorsState, setErrorsState] = useState(errors || {}); useEffect(() => { - return values && setValuesState(values); + values && setValuesState(values); }, [values]); useEffect(() => { - return errors && setErrorsState(errors); + errors && setErrorsState(errors); }, [errors]); const intl = useIntl(); diff --git a/src/components/form/select/select.tsx b/src/components/form/select/select.tsx index affb2823..6a8d64aa 100644 --- a/src/components/form/select/select.tsx +++ b/src/components/form/select/select.tsx @@ -130,8 +130,10 @@ export const Select: React.FC = ({ ); if (index === -1) { + setSelectedIndex(null); return; } + setSelectedIndex(index); }, [value, options]);