Skip to content
Source
Sign inSign up
TanStack/form

fix(form-core): report isValidating on every async validation run #2373

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

Showing 3 changed files with 57 additions and 0 deletions.

x
0 of 3 viewed, 3 left
5 additions and 0 deletions.changeset/wild-moons-repeat.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/form-core': patch
+---
+​
+Report `isValidating` on every async validation run instead of only the first one.
8 additions and 0 deletionspackages/form-core/src/FieldApi.tsModified
View file
@@ -1513,6 +1513,14 @@
field.timeoutIds.validations[validateObj.cause] = setTimeout(
async () => {
+ // The timer has fired, so this run is no longer waiting on a
+ // debounce. Release the id right away: the branch above uses a
+ // stored id to mean "a previous run is still pending" and
+ // compensates for it with `endValidation()`. Leaving a fired id
+ // behind makes the next run decrement the pending-validation
+ // counter for a run that already finished, which clears
+ // `isValidating` while that next run is still in flight.
+ field.timeoutIds.validations[validateObj.cause] = null
if (controller.signal.aborted) return rawResolve(undefined)
try {
rawResolve(
44 additions and 0 deletionspackages/form-core/tests/FieldApi.spec.tsModified
View file
@@ -892,6 +892,50 @@
storeunsub()