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

feature: use onBlur instead of native change event on FormControl change (Form package) #2715

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

elliason
Copy link

Description

I think using React's onBlur event is a better choice here for a few reasons:

  1. Imagine a hypothetical situation when user types incorrect input, he then clicks outside and input loose focus. Now the native onChange event is fired and the field is correctly marked as invalid. So the user goes back, fixes the input, field is marked as valid because of the resetControlValidity(); call on line 402. So far so good, but the user types again and unfortunately makes the same mistake as before and ends up with the same incorrect value in the input. If he now clicks outside and the input loses focus, the native onChange event is not fired at all because the value is the same as before. So the user is left with an incorrectly filled input without even realising it.
  2. It's less code, and you don't have to escape from the React event system to native events.

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

Successfully merging this pull request may close these issues.

None yet

1 participant