fix(combobox): update option list after clear
This commit is contained in:
parent
5516bec4ba
commit
ddea63b381
3 changed files with 31 additions and 0 deletions
5
.changeset/silver-lizards-repeat.md
Normal file
5
.changeset/silver-lizards-repeat.md
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@lion/ui': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
[combobox] update option list after clear
|
||||||
|
|
@ -1183,5 +1183,6 @@ export class LionCombobox extends LocalizeMixin(OverlayMixin(LionListbox)) {
|
||||||
clear() {
|
clear() {
|
||||||
super.clear();
|
super.clear();
|
||||||
this.value = '';
|
this.value = '';
|
||||||
|
this.__shouldAutocompleteNextUpdate = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -452,6 +452,30 @@ describe('lion-combobox', () => {
|
||||||
expect(el2._inputNode.value).to.equal('');
|
expect(el2._inputNode.value).to.equal('');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('updates option list after clear()', async () => {
|
||||||
|
const el = /** @type {LionCombobox} */ (
|
||||||
|
await fixture(html`
|
||||||
|
<lion-combobox name="foo" multiple-choice>
|
||||||
|
<lion-option .choiceValue="${'Artichoke'}">Artichoke</lion-option>
|
||||||
|
<lion-option .choiceValue="${'Chard'}">Chard</lion-option>
|
||||||
|
<lion-option .choiceValue="${'Chicory'}">Chicory</lion-option>
|
||||||
|
<lion-option .choiceValue="${'Victoria Plum'}">Victoria Plum</lion-option>
|
||||||
|
</lion-combobox>
|
||||||
|
`)
|
||||||
|
);
|
||||||
|
const options = el.formElements;
|
||||||
|
mimicUserTyping(el, 'a');
|
||||||
|
await el.updateComplete;
|
||||||
|
|
||||||
|
const visibleOptions = options.filter(o => o.style.display !== 'none');
|
||||||
|
expect(visibleOptions.length).to.equal(3, 'after input');
|
||||||
|
|
||||||
|
el.clear();
|
||||||
|
await el.updateComplete;
|
||||||
|
const visibleOptions2 = options.filter(o => o.style.display !== 'none');
|
||||||
|
expect(visibleOptions2.length).to.equal(0, 'after clear');
|
||||||
|
});
|
||||||
|
|
||||||
it('resets modelValue and textbox value on reset()', async () => {
|
it('resets modelValue and textbox value on reset()', async () => {
|
||||||
const el = /** @type {LionCombobox} */ (
|
const el = /** @type {LionCombobox} */ (
|
||||||
await fixture(html`
|
await fixture(html`
|
||||||
|
|
@ -923,6 +947,7 @@ describe('lion-combobox', () => {
|
||||||
expect(el.opened).to.equal(true);
|
expect(el.opened).to.equal(true);
|
||||||
|
|
||||||
const visibleOptions = options.filter(o => o.style.display !== 'none');
|
const visibleOptions = options.filter(o => o.style.display !== 'none');
|
||||||
|
expect(visibleOptions.length).to.not.equal(0);
|
||||||
visibleOptions.forEach((o, i) => {
|
visibleOptions.forEach((o, i) => {
|
||||||
expect(o.getAttribute('aria-posinset')).to.equal(`${i + 1}`);
|
expect(o.getAttribute('aria-posinset')).to.equal(`${i + 1}`);
|
||||||
expect(o.getAttribute('aria-setsize')).to.equal(`${visibleOptions.length}`);
|
expect(o.getAttribute('aria-setsize')).to.equal(`${visibleOptions.length}`);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue