fix(form-core): set isValidating synchronously before debounce delay#1971
fix(form-core): set isValidating synchronously before debounce delay#1971tt-a1i wants to merge 2 commits intoTanStack:mainfrom
Conversation
When async validation is scheduled with debounce, the `isValidating` flag was being set AFTER an await, causing a gap where callers would see `isValidating: false` during the debounce period. This caused form.canSubmit to be true when it should be false. The fix moves the `isValidating = true` assignment to happen synchronously, before any await, when async validators are detected. Fixes TanStack#1833
|
|
View your CI Pipeline Execution ↗ for commit b9dc82f
☁️ Nx Cloud last updated this comment at |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1971 +/- ##
==========================================
- Coverage 90.35% 89.48% -0.88%
==========================================
Files 38 48 +10
Lines 1752 1949 +197
Branches 444 488 +44
==========================================
+ Hits 1583 1744 +161
- Misses 149 184 +35
- Partials 20 21 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…eanup - Set current field's isValidating when linked fields have async validators (preserves original behavior) - Add vi.useRealTimers() cleanup to test
|
Hmmm ... I think the proposal makes sense. I'll do some digging to see if this is unintentional or not. Thanks for the PR! |
Summary
When async validation is scheduled with debounce, the
isValidatingflag was being set AFTER anawait, causing a gap where callers would seeisValidating: falseduring the debounce period. This causedform.canSubmitto betruewhen it should befalse.Before (bug):
isValidatingremainsfalseduring the debounce period ← BUGAfter (fix):
isValidatingis set totrueimmediately (synchronously)Changes
isValidating = trueassignment to happen synchronously, before anyawait, when async validators are detectedisValidatingis true during debounce periodTest plan
Fixes #1833
AI Assistance Disclosure
I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.