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: ensure user input is reverted before validation on blur #6163

Merged
merged 2 commits into from
Jul 14, 2023

Conversation

vursen
Copy link
Contributor

@vursen vursen commented Jul 14, 2023

Description

Fixes an issue where <combo-box required> didn't get invalidated after entering an invalid value and subsequently clicking outside. The issue occurred because combo-box triggered validation before reverting user input and from the perspective of the HTML constraint validation, it appeared as if combo-box had a value.

Along the way, the PR fixes combo-box-light not getting validated on blur and also adds the focused attribute for it.

Fixes #6164, vaadin/flow-components#5712

Type of change

  • Bugfix

@vursen vursen changed the title fix: validate on blur only after user input is reverted fix: ensure user input is reverted before validation on blur Jul 14, 2023
* @protected
* @override
*/
_setFocused(focused) {
Copy link
Contributor Author

@vursen vursen Jul 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: By moving the overlay closing logic to _setFocused, we ensure the correct sequence: the overlay closes first, and then the validation occurs.

@sonarcloud
Copy link

sonarcloud bot commented Jul 14, 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

@@ -87,6 +88,14 @@ describe('validation', () => {
expect(comboBox.validate()).to.be.true;
expect(comboBox.invalid).to.be.false;
});

it('should be invalid after user input is reverted on blur', async () => {
Copy link
Contributor Author

@vursen vursen Jul 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: The test that covers the issue.

@vursen vursen requested a review from web-padawan July 14, 2023 13:53
@vursen vursen marked this pull request as ready for review July 14, 2023 13:53
@@ -1029,7 +1029,7 @@ describe('lazy loading', () => {
let returnedItems;

const bluringDataProvider = (params, callback) => {
comboBox.blur();
comboBox.inputElement.blur();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: The combo-box-light doesn't delegate blur() calls to the input element.

@vursen vursen merged commit 753487e into main Jul 14, 2023
9 checks passed
@vursen vursen deleted the should-be-invalid-after-user-input-is-reverted-on-blur branch July 14, 2023 14:05
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.

[combo-box] Missing validation after entering an invalid value and blurring
2 participants