Repository navigation
fix(form-core): create complete field meta in setFieldValue for unmounted fields - #2433
maricastroc wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 76b33dc The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
🎯 Changes
form.setFieldValue()on a field with no mountedFieldApicreated incomplete metadata. ThesetFieldMetaupdater receivedundefinedand spread it, which left the new entry withouterrorSourceMap,isBlurred,isValidatingand the other default keys. A laterFormGroupvalidator that reported an error for that field then hitfieldMeta?.errorSourceMap[errorMapKey]indistributeFieldErrorsand threwTypeError: Cannot read properties of undefined (reading 'onChange'), aborting thehandleChangethat triggered validation.The fix defaults the updater parameter to
defaultFieldMeta((prev = defaultFieldMeta) =>), the same pattern used by the form-level error fan-out inFormApiand by #2233 inFormGroupApi. It fixes the inconsistent metadata where it is created instead of guarding the reader. Existing metadata for mounted fields is unchanged.Regression tests cover:
handleChangeno longer throws, the group error is assigned to the unmounted field with sourceform, it surfaces when the field mounts and clears once the value is fixedsetFieldValueon an unmounted field creating complete metadatasetFieldValuepreserving existing metadata (isBlurred, othererrorMapkeys,errorSourceMap) on a mounted fieldCloses #2432
✅ Checklist
pnpm test:pr, or these tests do not apply to this pull request.🚀 Release Impact
Summary by CodeRabbit