-
Notifications
You must be signed in to change notification settings - Fork 66
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
Validate on blur only after the user has typed something or triggered change event #5712
Comments
The proposal has been slightly clarified after an internal discussion. We've reached a consensus that the component should be marked as dirty in either of the following situations:
Note, for components that don't have an input element – such as CheckboxGroup, Select, etc – the change event will be the only trigger to make the component dirty. This implies that, for such components, the required validation will only occur when changing the value from non-empty to empty. For RadioGroup, it means that the required validation will never be triggered anymore (as radio buttons cannot be unchecked), unless the component is initially set as dirty. |
AFAICT, nice work of @vursen so far. I wrote a related SO question. It seems however there are not many complaints about this validation behaviour, which suprises me a little bit. Is there any estimation when the described solution might be available in a build? |
Hello, @tengcomplex! The work on the solution proposed in this ticket has been paused because, after conducting further research, we've found a potentially better approach that would also help resolve several other validation issues. It's currently in the Github discussion stage: https://github.com/orgs/vaadin/discussions/4434. Your feedback would be greatly appreciated. |
After more consideration, we've decided to treat "validation on blur" as a bug in Flow components caused by the new validation mechanism. Therefore, it will be only removed from the Flow components. The web components will continue to validate on blur as before. Follow #5537 for more details. |
Closing this as resolved for flow components as a part of #5537. Fix should be available in |
Describe your motivation
One of the actions that currently trigger field component validation is blur (when the component loses focus).
This behavior has been repeatedly pointed out as undesired in the case of the initial interaction, when the user leaves the field without entering anything:
Describe the solution you'd like
Change the default behavior to avoid validating on blur until the user has typed anything. Additionally, provide an option to revert the old behavior.
One way to implement that is to introduce a flag that would indicate whether the field is dirty. The field is considered dirty as soon as the user starts entering anything into it. This flag can be then used in blur handlers to determine whether the validation has to be run. Setting the flag initially to
true
would enforce the old behavior.Note, for components like date-picker and similar, the flag may need to be updated on some other actions as well.
The text was updated successfully, but these errors were encountered: