Skip to content

Commit 660f2d1

Browse files
fix: store last filter also when selecting item on click (#7639) (#7645)
Co-authored-by: Ugur Saglam <106508695+ugur-vaadin@users.noreply.github.com>
1 parent 0e40bcd commit 660f2d1

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

packages/multi-select-combo-box/src/vaadin-multi-select-combo-box-internal.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
358358
}
359359

360360
if (this.opened) {
361+
// Store filter value for checking if user input is matching
362+
// an item which is already selected, to not un-select it.
363+
this.lastFilter = this.filter;
364+
361365
this.dispatchEvent(
362366
new CustomEvent('combo-box-item-selected', {
363367
detail: {

packages/multi-select-combo-box/test/selecting-items.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ describe('selecting items', () => {
4242
expect(comboBox.selectedItems).to.deep.equal(['apple']);
4343
});
4444

45+
it('should unselect item on click when it was selected on Enter', async () => {
46+
await sendKeys({ down: 'ArrowDown' });
47+
await sendKeys({ type: 'apple' });
48+
await sendKeys({ down: 'Enter' });
49+
getFirstItem(comboBox).click();
50+
expect(comboBox.selectedItems).to.deep.equal([]);
51+
});
52+
4553
it('should not un-select item when typing its value manually', async () => {
4654
comboBox.selectedItems = ['orange'];
4755
await sendKeys({ down: 'ArrowDown' });

0 commit comments

Comments
 (0)