fix(form-core): clear errorSourceMap.onMount alongside errorMap.onMount - #2362
fix(form-core): clear errorSourceMap.onMount alongside errorMap.onMount#2362alliasgher wants to merge 1 commit into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthrough
ChangesForm error clearing
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This localized change clears stale field-error source metadata alongside the error itself and adds regression coverage for both supported sources; no actionable merge-blocking risk remains. Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Full details: Docstring CoverageExplanation No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
MILLERMARRU
left a comment
There was a problem hiding this comment.
Fix looks right for #2294. I traced the other field-meta writes to check the "every other write updates both maps together" claim: FieldApi.ts:889-890, 1324-1328, 1362-1366, 1561-1566 all pair errorMap with errorSourceMap, and FormApi.ts:2073-2077, 2289-2293, 2992-2996 do too. So setFieldValue was the one field-level omission and this closes it.
One spot that stays asymmetric after this PR: FormApi.ts:1566, errorMap = Object.assign(errorMap, { onMount: undefined }) in the base-store derived state (shouldInvalidateOnMount branch). That clears the form-level errorMap.onMount with no matching errorSourceMap write. It's only fine if the form-level base store has no errorSourceMap field at all (the errorSourceMap writes I found are all field-meta, none form-level). Could you confirm that's the case, so it's clear this isn't a second instance of the same bug one scope up? Separately, that line mutates currBaseStore.errorMap in place rather than copying, which is a pre-existing smell in a .state read but not something this PR needs to touch.
🎯 Changes
Fixes #2294.
FormApi.setFieldValueclearserrorMap.onMounton the field's meta but leaveserrorSourceMap.onMountuntouched, sofield.state.meta.errorSourceMap.onMountkeeps reporting a source ('field'or'form') for an error that no longer exists inerrorMap. Every other field-meta write inFormApi.tsupdates the two maps together, so this reads as an omission rather than intent.This adds the matching
errorSourceMapupdate inside the samesetFieldMetacall, and two regression tests inFormApi.spec.tscovering the'field'source (field-levelonMountvalidator) and the'form'source (form-levelonMountvalidator emitting a field error).alphais not affected:errorSourceMapdoes not appear in any package on that branch, so there is nothing to port to v2.Note that #2245 edits the same block for an unrelated reason. There is no functional overlap; happy to rebase if it lands first.
✅ Checklist
pnpm test:pr.🚀 Release Impact
Summary by CodeRabbit