canSubmit behavior is described inaccurately in documentation
In the documentation, the canSubmit property of the form state object is described as a "flag that is false when any field is invalid and the form has been touched". This doesn't accurately describe it's true behavior.
I've got a Next.js project where I'm using client and server validation in the same form. The following happens:
1. I fill out the form properly and canSubmit becomes true
2. I submit the form which doesn't pass server validation
3. The errors property of the form state object is now set, canSubmit is still true
4. I submit the same values again which still don't pass server validation
5. The errors property of the form state object remains the same, canSubmit is now false
What I'm getting at is that it seems like canSubmit also takes the form errors into account, not just any invalid field, and it's also flakey. Maybe something to do with the order in which things are happening.
Has anyone else experienced this behavior?
3 Replies
quickest-silver•6mo ago
I got the same issue, https://github.com/TanStack/form/issues/1300
GitHub
canSubmit not updated on first submission failed · Issue #1300 · Ta...
Describe the bug I'm not sure if this is a bug or intented, but If a form-level error is returned from server action in nextjs, the canSubmit property is not updated in the first submission, bu...
harsh-harlequinOP•6mo ago
Thank you so much for opening that issue. I was kind of surprised they hit a 1.0 release and nobody else noticed. I thought it was me.
genetic-orange•6mo ago
just got same error toðŸ˜