Skip to content

Commit

Permalink
fix: store last filter also when selecting item on click (#7639) (#7644)
Browse files Browse the repository at this point in the history
Co-authored-by: Ugur Saglam <[email protected]>
  • Loading branch information
vaadin-bot and ugur-vaadin authored Aug 12, 2024
1 parent be3400e commit e7134fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
8 changes: 8 additions & 0 deletions packages/multi-select-combo-box/test/selecting-items.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down

0 comments on commit e7134fd

Please sign in to comment.