Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: store last filter also on item click (#7639) (CP: 24.3) #7645

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading