diff --git a/src/components/form/fields/DateField.tsx b/src/components/form/fields/DateField.tsx index 79fbda05..05a9079d 100644 --- a/src/components/form/fields/DateField.tsx +++ b/src/components/form/fields/DateField.tsx @@ -33,24 +33,22 @@ export function DateField({ const { input, meta } = useField(name) - useEffect(() => { - if (input.value === '' && meta.touched && required) { + const handleChange: CalendarInputProps['onDateSelect'] = ( + payload: { + calendarDateString: string + validation?: ValidationProps + } | null + ) => { + if (!payload?.calendarDateString && required) { setValidation({ error: true, valid: false, validationCode: 'EMPTY', validationText: i18n.t('Required'), }) + } else { + setValidation(payload?.validation || { error: false }) } - }, [required, input.value, meta.touched]) - - const handleChange: CalendarInputProps['onDateSelect'] = ( - payload: { - calendarDateString: string - validation?: ValidationProps - } | null - ) => { - setValidation(payload?.validation || { error: false }) input.onChange(payload?.calendarDateString || '') input.onBlur() }