jaredpalmer / formik

Build forms in React, without the tears 😭
https://formik.org
Apache License 2.0
33.91k stars 2.78k forks source link

Incorrect dirty handling #3728

Closed quantizor closed 1 year ago

quantizor commented 1 year ago

At the moment dirty is a memoized field that compares the current values to the initial values. The thing is if someone ticks a checkbox and then unticks it, the form is still dirty but the dirty flag would reset to false because the values now match again.

Jittojoyes98 commented 1 year ago

Anyways of fixing this.Can we have a work around for Onchange ?

olzhas-kalikhan commented 1 year ago

have you considered "touched" state, I think the logic that if initialValues = currentValues then isDirty =true is correct

https://formik.org/docs/api/formik#touched--field-string-boolean-

quantizor commented 1 year ago

have you considered "touched" state, I think the logic that if initialValues = currentValues then isDirty =true is correct

https://formik.org/docs/api/formik#touched--field-string-boolean-

Hmm, you might be right. As long as it resets with enableReinitialize that would work.