feat(hooks): formState completeness + validation modes (isValidating, dirtyFields, onTouched, reValidateMode)#92
Merged
Conversation
isValidating + reactive dirtyFields on formState, plus mode:'onTouched' and opt-in reValidateMode. el-form-consistent MVP (flat dirtyFields, form-level isValidating boolean). Bundles the two smallest RHF-parity items. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
7 TDD tasks: additive fields+defaults, reactive dirtyFields, isValidating counter, mode:onTouched, reValidateMode, docs+changeset, verification. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…write + verified line refs)
…reset) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…dirty-record helper
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Final-review fix: the values-prop overwrite sync (keepDirtyValues:false) cleared the dirty Set + isDirty but left formState.dirtyFields stale, the one write site not routed through statePatch(). Route it through statePatch() so dirtyFields clears in lockstep with isDirty; lock in with a valuesSync assertion. Also refine the runValidating comment (submit/trigger wrap the whole pass) and document that validateOn overrides reValidateMode.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RHF-parity polish for
el-form-react-hooks— four additive, backward-compatible features. A form that uses none of them behaves exactly as before.Features
formState.isValidatingtruewhile validation is in flight. onChange/onBlur wrap only their async pass (validateFieldAsync);submit/handleSubmit/trigger()wrap the whole validation pass. Counter-based (pendingValidationsRef+runValidating), reset byreset().formState.dirtyFieldsPartial<Record<string, boolean>>(e.g.{ "profile.name": true }) — the reactive twin ofgetDirtyFields(). Written in lockstep withisDirtyvia a singledirtyState.statePatch()helper that replaces the ad-hocisDirty: size>0writes, so the two can never drift.mode: "onTouched"reValidateMode"onChange" | "onBlur" | "onSubmit". Once the form has been submitted, pins post-submit re-validation to the chosen event. Defaultundefined= unchanged.validateOnoverrides it.shouldValidateprecedence (final):validateOn>onSubmit>reValidateMode(when submitted) > smart-validation (with theonTouchedgate) >mode.Notes
isValidatingtask rewritten to wrap the new async methods rather than the sync pass (which would flicker the flag on every keystroke).valuesoverwrite sync clearedisDirtybut left the new reactivedirtyFieldsstale — the one write site not routed throughstatePatch(). Fixed (6cdd5c2) with a regression test.Testing
formstate-completeness,isValidating,onTouched,reValidateMode, + strengthenedvaluesSync). All TDD, each new test verified to fail without its implementation.build:packagessuccess (new fields confirmed indist/index.d.ts) · docs build passes.el-form-react-hooksminor.🤖 Generated with Claude Code