diff --git a/packages/multi-select-combo-box/src/vaadin-multi-select-combo-box-internal.js b/packages/multi-select-combo-box/src/vaadin-multi-select-combo-box-internal.js index f74fa70cfe..e13b7b8a0e 100644 --- a/packages/multi-select-combo-box/src/vaadin-multi-select-combo-box-internal.js +++ b/packages/multi-select-combo-box/src/vaadin-multi-select-combo-box-internal.js @@ -399,6 +399,10 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi } if (this.opened) { + // Store filter value for checking if user input is matching + // an item which is already selected, to not un-select it. + this.lastFilter = this.filter; + this.dispatchEvent( new CustomEvent('combo-box-item-selected', { detail: { diff --git a/packages/multi-select-combo-box/test/selecting-items.test.js b/packages/multi-select-combo-box/test/selecting-items.test.js index b7ee3b7013..e193a44b67 100644 --- a/packages/multi-select-combo-box/test/selecting-items.test.js +++ b/packages/multi-select-combo-box/test/selecting-items.test.js @@ -50,6 +50,14 @@ describe('selecting items', () => { expect(comboBox.selectedItems).to.deep.equal(['apple']); }); + it('should unselect item on click when it was selected on Enter', async () => { + await sendKeys({ down: 'ArrowDown' }); + await sendKeys({ type: 'apple' }); + await sendKeys({ down: 'Enter' }); + getFirstItem(comboBox).click(); + expect(comboBox.selectedItems).to.deep.equal([]); + }); + it('should not un-select item when typing its value manually', async () => { comboBox.selectedItems = ['orange']; await sendKeys({ down: 'ArrowDown' });