form icon indicating copy to clipboard operation
form copied to clipboard

Option to trigger onSubmitInvalid on every submit

Open beeirl opened this issue 11 months ago • 1 comments

Description Currently, onSubmitInvalid is designed to be called only once, due to this line of code. This behavior limits flexibility for handling invalid form submissions, as it prevents custom logic from being executed during validation.

Use Case I want to implement functionality where, if the form is resubmitted, the next field that still has an error gets focused. However, since onSubmitInvalid is only called once, this behavior isn't currently possible without workarounds.

Proposal Remove the guard to allow onSubmitInvalid to be called multiple times, or provide an explicit option to opt out of the current restriction.

beeirl avatar Jan 10 '25 18:01 beeirl

I just ran into the same issue when trying to integrate Tanstack Form with React Aria Components. My use case is exactly the same as described above - managing focus on invalid states. This is indeed possible with some "hacky" workarounds but being able to run the logic inside onSubmitInvalid would make things a lot cleaner.

origamisage avatar Jan 13 '25 12:01 origamisage