Skip to content

Commit

Permalink
fix: clear filter when clicking matching value (#3688)
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan authored Apr 18, 2022
1 parent 9b9fa8a commit df76091
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,20 @@ class MultiSelectComboBoxInternal extends ComboBoxDataProviderMixin(ComboBoxMixi
this._toggleElement = this.querySelector('.toggle-button');
}

/**
* Override method from `InputMixin`.
*
* @protected
* @override
*/
clear() {
super.clear();

if (this.inputElement) {
this.inputElement.value = '';
}
}

/** @protected */
_isClearButton(event) {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ class MultiSelectComboBox extends InputControlMixin(ThemableMixin(ElementMixin(P

/** @private */
__clearFilter() {
this.filter = '';
this.$.comboBox.clear();
}

Expand Down
16 changes: 16 additions & 0 deletions packages/multi-select-combo-box/test/basic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,22 @@ describe('basic', () => {
await sendKeys({ type: 'pear' });
await sendKeys({ down: 'Enter' });
expect(internal.value).to.equal('');
expect(inputElement.value).to.equal('');
});

it('should clear input element value after clicking matching value', async () => {
await sendKeys({ type: 'ora' });
const item = document.querySelector('vaadin-multi-select-combo-box-item');
item.click();
expect(internal.value).to.equal('');
expect(inputElement.value).to.equal('');
});

it('should clear filter property after clicking matching value', async () => {
await sendKeys({ type: 'ora' });
const item = document.querySelector('vaadin-multi-select-combo-box-item');
item.click();
expect(comboBox.filter).to.equal('');
});

it('should not add custom value to selectedItems automatically', async () => {
Expand Down

0 comments on commit df76091

Please sign in to comment.