diff --git a/src/useForm.ts b/src/useForm.ts index 7e76316..7995dcf 100644 --- a/src/useForm.ts +++ b/src/useForm.ts @@ -100,7 +100,7 @@ export function useForm(args: IUseFormArgs = {}) { await onSubmit(values) } catch (e) { - setErrors(normalizeServerErrors(e)) + updateErrors(normalizeServerErrors(e)) throw e } finally { diff --git a/src/useFormErrors.ts b/src/useFormErrors.ts index 854c316..d1658a5 100644 --- a/src/useFormErrors.ts +++ b/src/useFormErrors.ts @@ -74,6 +74,13 @@ export function useFormErrors(args: IUseFormErrorsArgs) { function updateTouched(changedTouched) { setTouched({...ctx.touched, ...replaceValues(changedTouched, true)}) + const untouchedExternalErrors = {...ctx.externalErrors} + Object.entries(changedTouched).forEach(([key, touched]) => { + if (touched) { + delete untouchedExternalErrors[key] + } + }) + setExternalErrors(untouchedExternalErrors) } const handleBlurProxy = useProxy(