Skip to content
Source
Sign inSign up
TanStack/form

fix(form-core): clear form errors only on change #2453

Opensuryaprakashsingh1705-sys(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/2453/headopened

Showing 2 changed files with 40 additions and 2 deletions.

x
0 of 2 viewed, 2 left
2 additions and 2 deletionspackages/form-core/src/FormApi.tsModified
View file
@@ -2112,7 +2112,7 @@
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
this.state.errorMap?.[submitErrKey] &&
- cause !== 'submit' &&
+ cause === 'change' &&
!hasErrored
this.baseStore.setState((prev) => ({
@@ -2132,7 +2132,7 @@
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
this.state.errorMap?.[serverErrKey] &&
- cause !== 'server' &&
+ cause === 'change' &&
!hasErrored
this.baseStore.setState((prev) => ({
38 additions and 0 deletionspackages/form-core/tests/FormApi.spec.tsModified
View file
@@ -2063,6 +2063,44 @@
).toBeUndefined()
+ it('should not clear form-level onSubmit error when a field is blurred without changing its value', async () => {
+ const form = new FormApi({
+ defaultValues: {