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

Validation delay is not synchonized with submit #120

Open
cventus opened this issue Apr 25, 2017 · 1 comment
Open

Validation delay is not synchonized with submit #120

cventus opened this issue Apr 25, 2017 · 1 comment

Comments

@cventus
Copy link

cventus commented Apr 25, 2017

I have a form that can be submitted many times. When a submission is successful the form is cleared out and the user is free to fill it in again.

The form contains a text field which is required. If the text field has focus when I press the submit button it loses focus and the onBlur event schedules the field to be validated after a 300ms delay. If the submission is very quick then the form is cleared out before the delayed validation happens and I end up with an error message next to the now empty field saying that it is required, even though everything actually went well.

Since validation occurs before onSubmit/onInvalidSubmit is called, I expected that to be enough and not for the delayed field validation to linger. Generally, any time the whole form is validated there should be no need to validate again unless something changes. I don't see a way to cancel the timeouts myself nor any way to reliably wait for them before clearing out the form.

Looking at src/Form.js, maybe the flush-validations timeout could be cleared in submit()?

@jquense
Copy link
Owner

jquense commented Apr 25, 2017

that seems reasonable yeah. If you want to put a PR together we can see if it causes any issues

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

2 participants