[REQUEST] Mark as no longer dirty when a field returns to its original value
bterrio opened this issue · comments
Is your feature request related to a problem? Please describe.
If, for example, a field representing a checkbox has its value change from true
to false
, back to true
again, I'd like to end up with dirty = false
for that field. In that case, submitting or resetting the form wouldn't change anything, so I'd like to know to keep those operations disabled.
Describe the solution you'd like
Is there perhaps already an option for this behavior, or a workaround?
Hi @bterrio,
Today, we do not do any value equality in the code and we don't want to do so because it might be difficult for some edge cases (e.g complex objects).
The field is mark dirty
as soon as its value changed once no matter if the value comes back to its original value.
Meaning: the user changed the value at least once.
However, there is a reset
function the is reset the value of your field to its original one and also set the dirty
property back to false
.
Thanks for answering @chainlist ! Ok, that's fair. In my case, I wouldn't mind if only primitives and strings were checked for equality, but I understand if that might not be what the majority is looking for
Related to this, I think it would be good to have a way to set the "original" value of a field. For example, saving a user's settings would set the original value of all the setting inputs to their current values, so only changes after the save would be considered as dirtying the field again.