Skip to content

Commit

Permalink
fix(react): allow to reset select value from outside
Browse files Browse the repository at this point in the history
  • Loading branch information
dackmin committed Jan 3, 2023
1 parent c9249b4 commit 141764c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/react/lib/SelectField/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,15 @@ const SelectField = forwardRef(({

useEffect(() => {
if (exists(value)) {
state.value = findOptions(value) || (value ?? (multiple ? [] : null));
dispatch({
value: state.value,
valid: onValidate(parseValue(state.value), { required, multiple }),
});
state.value = findOptions(value) || value;
} else {
state.value = multiple ? [] : null;
}

dispatch({
value: state.value,
valid: onValidate(parseValue(state.value), { required, multiple }),
});
}, [value, options]);

useLayoutEffect(() => {
Expand Down

0 comments on commit 141764c

Please sign in to comment.