form icon indicating copy to clipboard operation
form copied to clipboard

canSubmit is true when the form is touched but an invalid onChange field is not touched

Open naomiflagg opened this issue 8 months ago • 3 comments

Describe the bug

According to the docs, "canSubmit is true until the form has been touched, even if some fields are "technically" invalid based on their onChange/onBlur props". As far as I understand, field-level validations will only change canSubmit when that field has been touched, whereas form-level validations will affect canSubmit when any field has been touched. It would be helpful if this distinction could be made clear in the docs.

naomiflagg avatar May 08 '25 17:05 naomiflagg

The reason this happens is because the field validation has not yet run, so the first name field does not yet know it is invalid. Compare that to form validators which run when any field changes.

As far as I know, this is intended behaviour. However, you seem to be confused by the documentation on it, so this issue should target the misleading description.

LeCarbonator avatar May 12 '25 14:05 LeCarbonator

The reason this happens is because the field validation has not yet run, so the first name field does not yet know it is invalid. Compare that to form validators which run when any field changes.

As far as I know, this is intended behaviour. However, you seem to be confused by the documentation on it, so this issue should target the misleading description.

Thanks for clarifying. I updated the description, but kept it in the same issue for context even though it's not a bug.

naomiflagg avatar May 12 '25 16:05 naomiflagg

I suffer with same problem for required fields, I do thier validation in onMount but this show error messages, I want similar behavior to RHF where it compare validation with initial values, so it does not make error messages for somethings like those

I dont know but maybe onInit or edit onMount to dont fire errors for initial data

ws-rush avatar Sep 10 '25 20:09 ws-rush