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

fix: Fire validated event only when valid or validation changes #6294

Closed
wants to merge 3 commits into from

Conversation

TatuLund
Copy link
Contributor

@TatuLund TatuLund commented Aug 3, 2023

@TatuLund TatuLund changed the title fix: Fire validated event only when validation changes fix: Fire validated event only when valid or validation changes Aug 3, 2023
@vursen
Copy link
Contributor

vursen commented Aug 3, 2023

This optimization doesn't appear correct. While the field remains invalid, its invalidity can be caused by different reasons, requiring different error messages.

Example:

  1. Enter foo into a required date-picker => invalid due to bad input
  2. Remove "foo" => invalid due to an empty value

@vursen
Copy link
Contributor

vursen commented Aug 3, 2023

Potentially yes, but in our current implementation the user indication is empty error message, and field shakes and goes invalid state

This will become problematic once the error message support is added, see vaadin/flow-components#4618.

Another problem is that the optimization doesn't appear to work when the field becomes invalid due to a failed Binder validator. From the client's perspective, the field will be considered valid, so it will keep sending validated events on every key press until the validator eventually succeeds.

Therefore, relying exclusively on the client-side validity in such optimizations isn't reliable.

@vursen vursen closed this Aug 9, 2023
@vursen vursen reopened this Aug 9, 2023
@sonarcloud
Copy link

sonarcloud bot commented Aug 9, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@vursen
Copy link
Contributor

vursen commented Aug 9, 2023

I'm closing the PR due to the problems mentioned above.

@vursen vursen closed this Aug 9, 2023
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.

Server roundtrip on every key stroke in invalid fields
2 participants