keepDirtyOnReinitialize does not work with final-form-arrays
mjchang opened this issue · comments
Are you submitting a bug report or a feature request?
Bug Report
What is the current behavior?
When keepDirtyOnReinitialize
is true, pristine field array fields are not updated to the new initialValues.
What is the expected behavior?
Like non-field array fields, pristine fields should be updated to the new initial values.
Sandbox Link
https://codesandbox.io/s/react-final-form-field-arrays-jii92
What's your environment?
"final-form": "4.20.1",
"final-form-arrays": "3.0.2",
"react-final-form": "6.5.0",
Other information
Cause of the issue is with this block of code: https://github.com/final-form/final-form/blob/master/src/FinalForm.js#L766-L785.
The problem is safeFields
has both the array field itself and the array subfields. Using the codesandbox as an example, it would have both customers
and customers[0].firstName
and customers[1].lastName
. The inclusion of the array field itself is problematic because when setting the new form values, the entire array field is saved to the dirty value. Somehow the array field must be ignored.
Willing to accept a PR fixing this issue