You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What you were expecting:
When using a form input that is conditionally enabled/disabled by a switch:
Changing the input's value triggers validation and marks the field as dirty (i.e., isDirty becomes true).
Disabling the input should reset isDirty to false since validation shouldn't run on disabled inputs.
Re-enabling the input should allow it to become dirty again when its value is changed, triggering validation as expected.
What happened instead:
After re-enabling a previously disabled input, changing its value does not set isDirty to true, and validation is not triggered for that field.
Steps to reproduce:
Create a form with an input field that has validation and can be disabled/enabled based on a switch or another condition.
Change the value of the input and observe that validation runs as expected.
Disable the input, then re-enable it using the switch.
Change the input value again. Notice that validation does not run, and the field does not become dirty.
In this example, after toggling the switch, the "title" field can be submitted with an empty value, even though it is marked as required.
Other information:
After investigating, I believe this issue is caused by this PR. When the input is re-enabled, disabled = undefined is passed to react-hook-form's controller, but it seems the controller doesn't fully clear the disabled state internally, preventing the field from becoming dirty again.
Does the original issue with react-hook-form that the workaround was intended to fix still persist?
It seems like it was fixed here maybe we can remove that workaround.
The text was updated successfully, but these errors were encountered:
What you were expecting:
When using a form input that is conditionally enabled/disabled by a switch:
isDirty
becomestrue
).isDirty
tofalse
since validation shouldn't run on disabled inputs.What happened instead:
After re-enabling a previously disabled input, changing its value does not set
isDirty
totrue
, and validation is not triggered for that field.Steps to reproduce:
Reproduction Link:
In this example, after toggling the switch, the "title" field can be submitted with an empty value, even though it is marked as required.
Other information:
After investigating, I believe this issue is caused by this PR. When the input is re-enabled,
disabled = undefined
is passed toreact-hook-form
's controller, but it seems the controller doesn't fully clear the disabled state internally, preventing the field from becoming dirty again.Does the original issue with
react-hook-form
that the workaround was intended to fix still persist?It seems like it was fixed here maybe we can remove that workaround.
The text was updated successfully, but these errors were encountered: