fix(combobox): open on focused when showAllOnEmpty

This commit is contained in:
Thijs Louisse 2021-03-24 17:22:24 +01:00 committed by Joren Broekema
parent 72a6ccc81e
commit b7743d8f22
3 changed files with 21 additions and 1 deletions

View file

@ -8,4 +8,5 @@ Allow Subclassers of LionCombobox to set '\_syncToTextboxCondition' in closing p
## Fixes
Allow an extra microtask in registration phase to make forms inside dialogs compatible.
- form-core: allow an extra microtask in registration phase to make forms inside dialogs compatible.
- combobox: open on focused when showAllOnEmpty

View file

@ -390,6 +390,9 @@ export class LionCombobox extends OverlayMixin(LionListbox) {
*/
// eslint-disable-next-line class-methods-use-this
_showOverlayCondition({ lastKey }) {
if (this.showAllOnEmpty && this.focused) {
return true;
}
// when no keyboard action involved (on focused change), return current opened state
if (!lastKey) {
return this.opened;

View file

@ -177,6 +177,22 @@ describe('lion-combobox', () => {
el.autocomplete = 'both';
await performChecks();
});
it('shows overlay on focusin', async () => {
const el = /** @type {LionCombobox} */ (await fixture(html`
<lion-combobox name="foo" .showAllOnEmpty="${true}">
<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>
`));
expect(el.opened).to.be.false;
el._comboboxNode.dispatchEvent(new Event('focusin', { bubbles: true, composed: true }));
await el.updateComplete;
expect(el.opened).to.be.true;
});
});
});