Skip to content
Source
Sign inSign up
TanStack/form

fix(form-core): reset stale validation counter when shifting array meta #2247

Openxianjianlf2(GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromrefs/pull/2247/headopened

Showing 4 changed files with 43 additions and 4 deletions (loading 1).

x
0 of 4 viewed, 4 left
5 additions and 0 deletions.changeset/fix-array-removevalue-isvalidating-stuck.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/form-core': patch
+---
+​
+Fix `isFieldsValidating` getting stuck `true` after `removeValue` on an array field while an async validation is in flight
5 additions and 0 deletionspackages/form-core/src/FieldApi.tsModified
View file
@@ -1394,6 +1394,11 @@
* Ends tracking an async validation, decrementing the counter and clearing isValidating if no validations remain.
private endValidation() {
+ // The field may have been removed (e.g. via an array `removeValue`) while
+ // this async validation was still in flight. In that case its meta has
+ // already been deleted, so bail out instead of resurrecting empty meta.
+ // See https://github.com/TanStack/form/issues/2234
+ if (this.getInfo().instance !== this) return
this.setMeta((prev) => {
const newCount = Math.max(0, prev._pendingValidationsCount - 1)
return {
33 additions and 4 deletionspackages/form-core/src/metaHelper.tsModified
View file