react-final-form-arrays
react-final-form-arrays copied to clipboard
FieldArray becomes permanently dirty on change
Are you submitting a bug report or a feature request?
Bug
What is the current behavior?
If I change any field in a FieldArray, the state of the parent FieldArray changes to dirty and stays dirty even after reverting to the original state.
What is the expected behavior?
The top level FieldArray should revert to pristine state if the fields are returned to their original state.
Sandbox Link
I'd be happy to provide one if needed.
What's your environment?
- final-form: 4.9.1
- react-final-form: 3.6.5
- final-form-arrays: 1.1.0
- react-final-form-arrays: 1.0.6
- React: 16.4.1
Other information
https://github.com/final-form/react-final-form-arrays/blob/master/src/FieldArray.js#L78
Looking at where the FieldArray is registered, I see there is no equality comparator passed which would mean it defaults to a ===
check which would fail for an array.
I added a small snippet to enable addition of custom field level comparator to compare the arrays in my fork here: https://github.com/anant-singh/react-final-form-arrays/blob/dirty-field-check/src/FieldArray.js#L69-L88
We are having an issue with this as well. This bug is very old. Any intentions to fix this @erikras?
I'm really wondering if this is related to https://github.com/final-form/react-final-form/issues/709 wherein the underlying useField
hook is no longer providing updated meta for sub-fields. The issue is regarding meta.active
, but it's actually all meta data.