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
When using resetField() and setting value to anything different than the initial value, the dirty flag is not updated
const{
resetField,
meta,}=useField('name',yup.string(),{initialValue: 'Value'});// Make changes to field 'name'resetField({value: 'New Value'});// check value of meta.dirty (should be false, but is true)
This sets the input's value to New Value, but the input is still dirty.
But when using this code:
const{
resetField,
meta,}=useField('name',yup.string(),{initialValue: 'Value'});// Make changes to field 'name'resetField({value: 'Value'});// check value of meta.dirty (should be false, and is false)
Then the input's value is set back to Value and dirty flag is set to false
To reproduce
Steps to reproduce the behavior:
Attach resetField() method to input field using useField() and set an initialValue
Modify content of the input field
Trigger resetField() with a value different from initialValue from step 1 resetField({value: 'New Value'})
dirty flag in meta is not updated (still true)
Expected behavior
As I understand the resetField() method, it should reset the field's state (at least dirty flag IMO).
Did I misunderstand how resetField() should work or is this a bug?
If I use resetField() in a wrong way: Is there a solution to set a new value and reset the dirty flag?
Thank you!
The text was updated successfully, but these errors were encountered:
Versions
Describe the bug
When using
resetField()
and setting value to anything different than the initial value, the dirty flag is not updatedThis sets the input's value to
New Value
, but the input is still dirty.But when using this code:
Then the input's value is set back to
Value
and dirty flag is set tofalse
To reproduce
Steps to reproduce the behavior:
resetField()
method to input field usinguseField()
and set aninitialValue
resetField()
with a value different frominitialValue
from step 1resetField({value: 'New Value'})
dirty
flag in meta is not updated (stilltrue
)Expected behavior
As I understand the
resetField()
method, it should reset the field's state (at leastdirty
flag IMO).Did I misunderstand how
resetField()
should work or is this a bug?If I use
resetField()
in a wrong way: Is there a solution to set a new value and reset the dirty flag?Thank you!
The text was updated successfully, but these errors were encountered: