-
-
Notifications
You must be signed in to change notification settings - Fork 582
fix: flatten errors consistently when validating before field mount #2003
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: flatten errors consistently when validating before field mount #2003
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
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks for the fix!
🎯 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