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

If onBlur is undefined, it automatically validates the fields even if they don't change #1115

Open
Rick-Phoenix opened this issue Jan 15, 2025 · 0 comments

Comments

@Rick-Phoenix
Copy link

Describe the bug

If an input has onBlur set to field.handleBlur, but onBlur is not defined on a field or form level, the onBlur event (just clicking on an element and clicking away from it) makes the field valid even if nothing has changed.

Your minimal, reproducible example

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

Steps to reproduce

  1. Type anything on username
  2. Type 11 on age
  3. Click submit
  4. Now click on the username field and click away from it
  5. canSubmit and isFormValid will turn from false to true

Expected behavior

Just clicking on an input and outside of it should not change canSubmit to true

How often does this bug happen?

Every time

Screenshots or Videos

No response

Platform

  • Chrome (stackblitz)
  • Chrome (Windows 11)

TanStack Form adapter

None

TanStack Form version

0.41.1

TypeScript version

5.7.3

Additional context

I kind of noticed this by accident as I left the onBlur property in one of my inputs after copying one of the examples from the docs.
Technically not a 'real' bug as it comes from user mistake but still, it is not the correct behavior for onBlur to validate fields automatically if it is not defined.

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