Skip to content
Source
Sign inSign up
TanStack/form

fix(form-core): clear stale onMount error on linked-field revalidation #2244

Openxianjianlf2(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/2244/headopened

Showing 3 changed files with 84 additions and 1 deletion.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/clear-stale-onmount-linked-revalidation.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+"@tanstack/form-core": patch
+---
+​
+fix(form-core): clear a stale field-level `onMount` error when a linked-field revalidation (`onChangeListenTo`/`onBlurListenTo`) passes, so the field is no longer left permanently invalid
28 additions and 1 deletionpackages/form-core/src/FieldApi.tsModified
View file
@@ -1292,6 +1292,7 @@
const validateFieldFn = (
field: AnyFieldApi,
validateObj: SyncValidator<any>,
+ isLinkedField = false,
) => {
const errorMapKey = getErrorMapKey(validateObj.cause)
@@ -1334,6 +1335,32 @@
if (newErrorValue) {
hasErrored = true
+​
+ // A direct value change clears the mount-time error in
+ // `setFieldValue`. When a field is revalidated indirectly via