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: avoid clearing filter when pressing clear button on mobile (#7091) (CP: 24.3) #7092

Merged
merged 1 commit into from
Jan 18, 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 @@ -1053,6 +1053,9 @@ class MultiSelectComboBox extends ResizeMixin(InputControlMixin(ThemableMixin(El
_onClearButtonTouchend(event) {
// Cancel the following click and focus events
event.preventDefault();
// Prevent default combo box behavior which can otherwise unnecessarily
// clear the input and filter
event.stopPropagation();

this.clear();
}
Expand Down
11 changes: 11 additions & 0 deletions packages/multi-select-combo-box/test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,17 @@ describe('basic', () => {
clearButton.dispatchEvent(new CustomEvent('touchend', { cancelable: true }));
expect(comboBox.selectedItems).to.deep.equal([]);
});

it('should not clear filter on clear button touchend', async () => {
comboBox.selectedItems = ['apple', 'orange'];
inputElement.focus();
await sendKeys({ type: 'app' });

clearButton.dispatchEvent(new CustomEvent('touchend', { cancelable: true, bubbles: true }));
expect(inputElement.value).to.equal('app');
expect(comboBox.filter).to.equal('app');
expect(comboBox.filteredItems).to.deep.equal(['apple']);
});
});

describe('toggle button', () => {
Expand Down