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

Validation error not cleared after unmounting Field with validate

Open
#615 2 comments 4 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
7.4k
Forks
497
PR merge metrics
No merged PRs in 30d

Description

### Are you submitting a **bug report** or a **feature request**?

Bug report or request for making clear in docs that doing the following is forbidden

### What is the current behavior?

1. Use the `Field` with the same `name` more then once and specify some validation on one of them
2. Unmount only the one with `validate` prop on it
3. See the validation error never being cleared nor changed even if you change the field value

On the following example you can mount and unmount `Field` with `validate` on it by using checkbox. Below the `errors`, `valid` and `values` of form are shown.
https://codesandbox.io/embed/react-final-form-unmounting-validation-bug-doocv

### What is the expected behavior?

Unmounting `Field` should also clear validation errors previously produced by `validate` on this Field.

Additional info: desired behaviour can be observed if you unmount all occurences of `Field` with the same `name`.

### Sandbox Link

https://codesandbox.io/embed/react-final-form-unmounting-validation-bug-doocv

### What's your environment?

As seen in CodeSandbox example:
"final-form": "4.8.15",
"react": "16.9.0",
"react-dom": "16.9.0",
"react-final-form": "6.3.0"

Run on Chrome 74, Windows.

### Other information

Desired behaviour can be observed if you unmount all occurences of `Field` with the same `name`.

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.