Skip to content

keepDirtyOnReinitialize does not work with final-form-arrays #366

Description

@mjchang

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions