Skip to content

Commit

Permalink
feat(radio-field): dispatch onValidate when value change
Browse files Browse the repository at this point in the history
  • Loading branch information
maximedasilva committed Oct 19, 2022
1 parent 98fd799 commit 025430e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/react/lib/RadioField/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@ const RadioField = forwardRef(({
if (
parseValue(value) !== state.value
) {
const valid = onValidate(value, { dirty: state.dirty, required });
dispatch({
value: options?.find(o => parseValue(o) === value),
valid: onValidate(value, { dirty: state.dirty, required }),
valid,
});
updateControl?.({
dirty: state.dirty,
valid,
});
}
}, [value, options]);
Expand Down
2 changes: 0 additions & 2 deletions packages/theme/lib/RadioField.sass
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,3 @@
&.invalid
label
border: 1px solid var(--junipero-grapefruit)


0 comments on commit 025430e

Please sign in to comment.