Skip to content

fix: preserve submission callback rejections without a reason - #13967

Merged
bluebill1049 merged 2 commits into
react-hook-form:masterfrom
charan-rathore:fix/on-valid-falsy-rejection
Oct 31, 2026
Merged

bluebill1049 merged 2 commits into
react-hook-form:masterfrom
charan-rathore:fix/on-valid-falsy-rejection

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

Proposed Changes

handleSubmit(() => Promise.reject())() currently fulfills and sets isSubmitSuccessful to true. The callback failed, but its rejection reason is undefined, so the truthiness checks treat it as a successful submission.

Track whether onValid failed separately from its error value. Rethrow the original reason and keep isSubmitSuccessful false for synchronous throws and rejected promises with undefined, null, false, 0 or an empty string. Keep the existing submitted state and submit count behavior.

Added ten regression cases using the real form hook. This is separate from #13905's validation and onInvalid exception handling. No new dependencies or public API changes. No linked issue.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes

Validation on Node 22.23.4 and pnpm 11.28.10: 130 suites, 1,800 tests and 26 snapshots pass. Both type checks, builds, export checks, API Extractor and changed-file lint/format checks pass. Full lint has no errors and 572 existing warnings; API Extractor retains its TypeScript-version advisory. All 90 Chromium browser tests pass in the final full run. Reverting only the implementation makes all ten added cases fail; restoring it passes all 50 submit tests. The normal pre-commit checks pass.

Prepared with AI assistance (Codex and Instinct); the final two-file diff and validation evidence were reviewed. The local results apply to commit 5731b3a, based on 8eef3e0; current master 3f1257c merges cleanly, but the combined tree was not separately retested locally.

@bluebill1049
bluebill1049 merged commit 7e2df21 into react-hook-form:master Oct 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants