Skip to content

Commit

Permalink
fix: show error on change
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Jun 20, 2023
1 parent 673bb91 commit ffbce97
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/form/CheckboxField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ const CheckboxField: React.FC<CheckboxFieldProps> = ({
return (
<Field {...fieldConfig}>
{({ form, meta }: FieldProps) => {
const [showError, setShowError] = React.useState(false);

onChange = wrap({
after: (_, checked) => {
setShowError(true);
form.setFieldValue(name, checked, true);
}
}, onChange);
Expand All @@ -87,7 +90,7 @@ const CheckboxField: React.FC<CheckboxFieldProps> = ({
/>}
{...formControlLabelProps}
/>
{meta.error !== undefined && meta.error !== '' &&
{showError && ![undefined, ''].includes(meta.error) &&
<ClickableTooltip title={meta.error}>
<ErrorIcon className='checkbox-error' />
</ClickableTooltip>
Expand Down

0 comments on commit ffbce97

Please sign in to comment.