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

The form's isValid state changes to true even if async validation is not yet finished. #1140

Open
mariansimecek opened this issue Feb 6, 2025 · 1 comment

Comments

@mariansimecek
Copy link

Describe the bug

I'm not sure if this is a feature or not, but I would expect that when a field is using an async validator and it hasn't finished yet, the form should not change its isValid state to true.

For example, this allows the form to be submitted before validation is complete.

  • I also tried setting defaultState: { isValid: false }, but it did not work as expected. Form always defaults to isValid: true
  • It also behaves weirdly when you click outside of the input while the field is currently validating.

Your minimal, reproducible example

https://stackblitz.com/edit/tanstack-form-tofchgxp?file=src%2Findex.tsx

Steps to reproduce

  1. open example
  2. type anything into input
  3. wait for validation
  4. type anything again
  5. form will change to isValid:true

Expected behavior

I would expect that form will never change isValid until validator is done

How often does this bug happen?

Every time

Screenshots or Videos

bug-report.mp4

Platform

Google chrome

TanStack Form adapter

react-form

TanStack Form version

0.41.3

TypeScript version

No response

Additional context

No response

@Balastrong
Copy link
Member

This probably gets philosophical but while validation is in process it wouldn't be correct to say it's not valid as technically you don't know (yet)

I think a combination of isValid && !isValidating is what you might be looking for

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