fix(form-core): flatten errors consistently when validating before field mount#2003
Merged
LeCarbonator merged 2 commits intoTanStack:mainfrom Jan 23, 2026
Merged
Conversation
🦋 Changeset detectedLatest commit: b1b17cf The changes in this PR will be included in the next version bump. This PR includes changesets to release 13 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
6bbed2c to
81b649f
Compare
81b649f to
86447ba
Compare
|
View your CI Pipeline Execution ↗ for commit b1b17cf
☁️ 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 #2003 +/- ##
==========================================
- Coverage 90.35% 89.46% -0.90%
==========================================
Files 38 48 +10
Lines 1752 1945 +193
Branches 444 488 +44
==========================================
+ Hits 1583 1740 +157
- Misses 149 184 +35
- Partials 20 21 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
LeCarbonator
approved these changes
Jan 23, 2026
Contributor
LeCarbonator
left a comment
There was a problem hiding this comment.
LGTM! Thanks for the fix!
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🎯 Changes
Fixes #1993
Fixed an issue where
field.errorswas incorrectly nested as[[error]]instead of[error]whenform.validate()was called manually before a field was mounted.Problem:
The
flat(1)operation inFormApi.validateSync()only applied whenfieldInstanceexisted, causing unmounted fields to retain nested error arrays. This led to inconsistent error structure:['Error message']✅[['Error message']]❌Solution:
Changed the condition from
if (fieldInstance && !disableErrorFlat)toif (!fieldInstance || !disableErrorFlat)to applyflat(1)by default unlessdisableErrorFlatis explicitly true. This inverts the logic to "should flatten" rather than "should not flatten", ensuring unmounted fields are flattened correctly.Changes:
✅ Checklist
pnpm test:pr.🚀 Release Impact