-
-
Notifications
You must be signed in to change notification settings - Fork 527
fix(form-core): prevent runtime errors when using deleteField
#1706
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
Conversation
View your CI Pipeline Execution ↗ for commit 842956e
☁️ Nx Cloud last updated this comment at |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1706 +/- ##
==========================================
+ Coverage 90.35% 90.44% +0.09%
==========================================
Files 38 38
Lines 1752 1790 +38
Branches 444 453 +9
==========================================
+ Hits 1583 1619 +36
- Misses 149 151 +2
Partials 20 20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Please, verify the idea. If I'm thinking in a proper direction I will proceed and add unit tests. |
@LeCarbonator? :) |
Will try to review this in the coming days |
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.
I'm not convinced this would be the ideal solution, but this minor fix helps catch the irritating runtime errors. Thanks for the step-by-step explanation!
🦋 Changeset detectedLatest commit: 842956e The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 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 |
deleteField
During implementing this and testing
deleteField
I found out that this method does not work.When a form field has
onChange
validation and thedeleteField
method is called on it, an error appears.error: https://bolt.new/~/vitejs-vite-ceu2fl73
I think flow look like this:
form.deleteField('firstName')
.values
soonChange
validator runs.errors.fields.email = 'error message'
- sovalidateSync
tries to update metadata of deleted field.setFieldMeta
callsfunctionalUpdate
withundefined
(since field does not exists infieldMetaBase
)....prev
whereprev
now is undefined -> error.So
validateSync
iterates through field list that already semes to be outdated. There is a checkif (!fieldMeta)
in this function but I guess we have to add as wellif (!fieldMetaBase)
.