Skip to content

Commit

Permalink
fix: store last filter also when selecting item on click (#7639) (#7645)
Browse files Browse the repository at this point in the history
Co-authored-by: Ugur Saglam <106508695+ugur-vaadin@users.noreply.github.com>
  • Loading branch information
vaadin-bot and ugur-vaadin authored Aug 12, 2024
1 parent 0e40bcd commit 660f2d1
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 @@ -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: {
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 @@ -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' });
Expand Down

0 comments on commit 660f2d1

Please sign in to comment.