| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
The submit-error auto-clear in FieldApi.validateSync fired on every non-submit validation cause, including blur. As a result, focusing and leaving a field without editing it dropped a valid submit error. Gate the clear on a value `change` cause so the error is only removed when the user actually enters a new value, matching the documented intent of the block. Closes TanStack#1242
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 5e7097f8-a41c-492e-b209-cf17699f7708 📥 CommitsReviewing files that changed from the base of the PR and between 6a73479 and 1d7dbe6. 📒 Files selected for processing (2)
📝 Walkthrough WalkthroughFieldApi.validateSync is updated to clear the stored onSubmit error only when cause === 'change', instead of when cause !== 'submit'. Two tests are added: one confirming the error persists after a post-submit blur, and one confirming it clears after a valid handleChange. ChangesonSubmit error lifecycle fix
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem🚥 Pre-merge checks | ✅ 5 ✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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. ❤️ ShareComment @coderabbitai help to get the list of available commands and usage tips. |
Sorry, something went wrong.
There was a problem hiding this comment.
Checked ValidationCause and it's 'change' | 'blur' | 'submit' | 'mount' | 'server' | 'dynamic', so the old cause !== 'submit' was clearing a stale onSubmit error on blur, mount, server and dynamic validations too, not just on an actual value change. cause === 'change' is the right fix, it only clears the error for the one cause that actually means "the user entered something new," which is what the surrounding comment already claimed the code was doing.
The two new tests cover the pair that matters, blurring an untouched field keeps the error, entering a valid value clears it, and neither the FieldApi type nor any caller elsewhere seems to rely on the old broader clearing behavior.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Closes #1242
Problem
A field-level onSubmit error is wrongly cleared when the user focuses and blurs the field without changing its value. The submit error should only disappear once the user actually enters a (valid) value.
Root cause
In FieldApi, the logic that clears a stored submit error fired for any cause other than 'submit':
handleBlur runs validation with cause: 'blur', which satisfied cause !== 'submit', so a plain blur (no edit) cleared the submit error.
Fix
Clear the stored submit error only on an actual value change:
A blur (or any non-value cause) no longer drops the submit error. Entering a valid value still clears it as documented.
Tests
Two tests added to packages/form-core/tests/FieldApi.spec.ts:
Full form-core suite green (107 tests).
Summary by CodeRabbit
Bug Fixes
Tests