Skip to content

When using async field-level validation, the validating FieldState gets reset to false even if validation is ongoing #491

Description

@mynamesleon

Are you submitting a bug report or a feature request?

Bug report

What is the current behavior?

When using asynchronous field-level validation, the validating state is initially set to true when the validation is triggered. However, if you make another change (and trigger the validate function again) while the first one is ongoing, the validating FieldState is then reset to false when the first Promise fulfills, even though the second one is still ongoing. So the field is technically still validating, but the FieldState doesn't reflect this.
E.g. set up an async validate function that returns an error after 2 seconds. Make a change to your field, then 1 second later, make another change.

What is the expected behavior?

The validating property on the FieldState correctly indicates if validation is ongoing.

Sandbox Link

https://codesandbox.io/p/sandbox/final-form-async-field-issue-hd93sm

What's your environment?

Latest versions

Other information

I have included instructions in the codesandbox link as well.
(I've set this up using react-final-form for ease, but it's reproducible with just final-form as well.)

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