jaredpalmer / formik

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

Add localised dirty check to fix autocomplete #3810

Open silvanaweb opened 1 year ago

silvanaweb commented 1 year ago

Feature request

Current Behaviour

At the moment there is no way (after a deep search in Formik properties) to detect if another field has been changed by browser autocomplete, when a field is changed. That means that, for example, we can show errors on validation for the autocompleted input that has "not been touched" directly. We were using the "touched" property to detect the change, but that is triggered on blur of the touched field, not on change of other fields being changed. Now I am using "dirty", but that is form related, not field related, so it gives me a partial solution.

Desired Behaviour

I would like to be able to know when, on autocomplete, another field has been changed, apart from the one that has been touched.

Suggested Solution

The suggested solution could be having a dirty (or pristine) that is localised to inputs like touched, so that we can understand when a field has been changed on autocomplete. Or it could be called changedValues.

Who does this impact? Who is this for?

It is to fix a bug we have at the moment, that on autocomplete the error is not showed on another field that has not been directly touched.

Describe alternatives you've considered

Additional context

quantizor commented 1 year ago

if another field has been changed by browser autocomplete, when a field is changed

Does a change event not get fired as a result of autocomplete?

silvanaweb commented 1 year ago

No. i think formik trigger validation on blur.