submitErrors unexpectedly disappears when both errors (syncErrors) and submitErrors exist
leannechen opened this issue · comments
Are you submitting a bug report or a feature request?
Bug report
What is the current behavior?
When submitting form with both syncErrors
and submitErrors
, submitErrors
from previous submit unexpectedly disappears without having an updated one.
Steps to reroduce the problem
- Create a form with Field A, with validation:
- On input change: Check if input value exceed max-length (e.g. 20).
- On submit: Check required (i.e. "This field is required" hint).
- Create another Field B, with validation:
- On submit: Check required.
- Submit. All fields should have the "required" error now.
- Edit Field A to make the input value exceed max-length, which will result in a field validate error.
- Submit again.
- Current Result: The "required" error on Field B disappears.
What is the expected behavior?
The "required" error on Field B exists.
What's your environment?
- "final-form": "^4.20.2",
- "react-final-form": "^6.5.2",
Other information
See Line 1090:
Line 1090 in 6a28f52
Here, the submitErrors
is deleted before checking hasSyncErrors
. If we have any syncError (or errors
, to be specific) here, submitErrors
will be deleted, and the function will stop executing before generating an updated submitErrors
.
However, it is more reasonable that the deleting and re-generating submitErrors
codes should be run or not run at the same time, and not the other way in which only deleting occurs without re-generating.
This way, submitErrors
won't be unintendedly affected by whether syncErrors
exist.