final-form / final-form/react-final-form-arrays

FieldArray becomes permanently dirty on change

Open
#37 2 comments 13 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
210
Forks
69
PR merge metrics
No merged PRs in 30d

Description

### 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.