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 a732032652..415b564957 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 @@ -358,6 +358,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 97a2f2d4c7..d8d9898762 100644 --- a/packages/multi-select-combo-box/test/selecting-items.test.js +++ b/packages/multi-select-combo-box/test/selecting-items.test.js @@ -42,6 +42,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' });