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: consider a value matching selected item label a known value #3302

Merged
merged 1 commit into from
Jan 18, 2022

Conversation

tomivirkki
Copy link
Member

@tomivirkki tomivirkki commented Jan 18, 2022

Part of vaadin/flow-components#2524

This change fixes the main issue in vaadin/flow-components#2524:
The "custom-item-set" event was dispatched even when the value matched the label of comboBox.selectedItem.

There's still another issue related to vaadin/flow-components#2524 (the dropdown doesn't populate on the first open after setting new items) but it will be fixed separately.

@sonarqubecloud
Copy link

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

Comment on lines -98 to +104
await aTimeout(0);
await nextFrame();

comboBox.value = comboBox.items[50];
comboBox.close();

comboBox.open();
await aTimeout(0);
await nextFrame();
Copy link
Member Author

Choose a reason for hiding this comment

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

This test was failing on master also for some reason. Changed the timings in the test to make it pass.


// Try to find an item whose label matches the input value. A matching item is searched from
// the filteredItems array (if available) and the selectedItem (if available).
const itemMatchingByLabel = [...(this.filteredItems || []), this.selectedItem].find((item) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

Cleaned up the logic a bit, but the main change here is that matching items are no longer searched only from the filteredItems array (which gets cleared by comboBoxConnector, producing the original bug) but also from selectedItem.

@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with platform 23.0.0.alpha3 and is also targeting the upcoming stable 23.0.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants