Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

submitErrors unexpectedly disappears when both errors (syncErrors) and submitErrors exist #437

Open
leannechen opened this issue Oct 7, 2021 · 0 comments

Comments

@leannechen
Copy link

leannechen commented Oct 7, 2021

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

  1. Create a form with Field A, with validation:
    1. On input change: Check if input value exceed max-length (e.g. 20).
    2. On submit: Check required (i.e. "This field is required" hint).
  2. Create another Field B, with validation:
    1. On submit: Check required.
  3. Submit. All fields should have the "required" error now.
  4. Edit Field A to make the input value exceed max-length, which will result in a field validate error.
  5. Submit again.
  6. 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:

delete formState.submitErrors;

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.

@leannechen leannechen changed the title submitErrors unexpectedly disappears when having both errors / syncErrors and submitErrors submitErrors unexpectedly disappears when both errors (syncErrors) and submitErrors exist Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant