Skip to content
Source
Sign inSign up
TanStack/form

`form.onSubmitInvalid` not called when `canSubmit` is false #1696

Send to my agent
ClosedPascalmh(GitHub profile, opens in a new tab) opened this issue 0 comments

Describe the bug

When handleSubmit is called while canSubmit is false an early return is hit and onSubmitInvalid is not called.

https://github.com/TanStack/form/blob/1e58e57987e4f79fb23d0034d1cdceebb9a7299b/packages/form-core/src/FormApi.ts#L1918

Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-form-dqy8vhes?file=src%2Findex.tsx

Steps to reproduce

  1. Go to the Stackblitz
  2. 👁️ Observe: "canSubmit": false, (see JSON-dump in <pre>-Tag)
  3. Click the Submit Button
  4. 👁️ Observe: No console.log for "onSubmitInvalid"

Expected behavior

As a User I expect form.onSubmitInvalid to be called whenever the form is submitted in an invalid state

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

irrelevant

TanStack Form adapter

react-form

TanStack Form version

1.19.2

TypeScript version

No response

Additional context

No response

Sign in to join this conversation.