Skip to content

feat(hooks): add isSubmitted/isSubmitSuccessful/submitCount to formState - #82

Merged
colorpulse6 merged 2 commits into
mainfrom
feat/formstate-completeness
Jun 9, 2026
Merged

feat(hooks): add isSubmitted/isSubmitSuccessful/submitCount to formState#82
colorpulse6 merged 2 commits into
mainfrom
feat/formstate-completeness

Conversation

@colorpulse6

Copy link
Copy Markdown
Owner

Roadmap item P2 (first slice) — formState completeness. Adds the most commonly-used React Hook Form status fields el-form was missing:

field meaning
isSubmitted true after the first submit attempt
submitCount number of submit attempts
isSubmitSuccessful true when the last submit passed validation and the handler ran without throwing

All three are reset by reset() (and resetValues/restoreSnapshot), and set consistently across handleSubmit, submit(), and submitAsync().

Implementation

  • Added to the FormState type; defaults at the four full-FormState creation sites; set in submitOperations (start: isSubmitted: true, submitCount: prev+1, isSubmitSuccessful: false; on success: isSubmitSuccessful: true after the handler resolves — if it throws, that line is skipped so it stays false).
  • Spread-based setFormState updaters inherit the new fields automatically.

Verification

  • 7 runtime tests: initial defaults, valid submit(), invalid submit() (success stays false), handleSubmit path, count increment, throwing-handler (success false, count still increments, rejection propagates), and reset() clearing.
  • build + hooks (130) + tsd + components (26) + umbrella (6) green; lint clean.
  • Independent review SOUND — confirmed all creation sites covered, semantics RHF-aligned; flagged two stale type-fixtures (now fixed) and the throwing-handler test (now added).

Additive minor (el-form-react-hooks); el-form-react picks it up via dependent bump. Fast-follow (P2b): isValidating + a reactive dirtyFields field.

🤖 Generated with Claude Code

colorpulse6 and others added 2 commits June 9, 2026 21:25
RHF-parity submit-status fields, set consistently across handleSubmit, submit(),
and submitAsync(): isSubmitted (true after first attempt), submitCount (per
attempt), isSubmitSuccessful (true only when validation passed AND the handler
ran without throwing). All reset by reset()/resetValues()/restoreSnapshot().

7 runtime tests (valid/invalid submit, handleSubmit, count increment, reset,
throwing-handler) + updated 2 unit-test fixtures for the new required fields.
Additive, minor. (isValidating + reactive dirtyFields are the fast-follow.)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@github-actions github-actions Bot added the ready to publish This PR contains a Changeset and is ready to be published. label Jun 9, 2026
@colorpulse6
colorpulse6 merged commit 9510048 into main Jun 9, 2026
8 checks passed
@colorpulse6
colorpulse6 deleted the feat/formstate-completeness branch June 9, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready to publish This PR contains a Changeset and is ready to be published.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant