Skip to content

form.onSubmitInvalid not called when canSubmit is false #1696

@Pascalmh

Description

@Pascalmh

Describe the bug

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

if (!this.state.canSubmit) return

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions