From 943618fdcb60e054f857c0d93e4be51f92fe60da Mon Sep 17 00:00:00 2001 From: gvangeest Date: Thu, 23 Feb 2023 11:34:11 +0100 Subject: [PATCH] fix(combobox): fix direct open and closing of the overlay on focus of empty input when showAllOnEmpty --- .changeset/chilly-plants-cry.md | 5 +++++ .../components/combobox/src/LionCombobox.js | 1 + .../combobox/test/lion-combobox.test.js | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 .changeset/chilly-plants-cry.md diff --git a/.changeset/chilly-plants-cry.md b/.changeset/chilly-plants-cry.md new file mode 100644 index 000000000..26fa17ebf --- /dev/null +++ b/.changeset/chilly-plants-cry.md @@ -0,0 +1,5 @@ +--- +'@lion/ui': patch +--- + +[combobox] fix direct open and closing of the overlay on focus of empty input when `showAllOnEmpty` diff --git a/packages/ui/components/combobox/src/LionCombobox.js b/packages/ui/components/combobox/src/LionCombobox.js index 6d7af9267..a606f1329 100644 --- a/packages/ui/components/combobox/src/LionCombobox.js +++ b/packages/ui/components/combobox/src/LionCombobox.js @@ -856,6 +856,7 @@ export class LionCombobox extends OverlayMixin(LionListbox) { ...withDropdownConfig(), elementToFocusAfterHide: undefined, invokerNode: this._comboboxNode, + visibilityTriggerFunction: undefined, }); } diff --git a/packages/ui/components/combobox/test/lion-combobox.test.js b/packages/ui/components/combobox/test/lion-combobox.test.js index 40414ae1b..ee483f41a 100644 --- a/packages/ui/components/combobox/test/lion-combobox.test.js +++ b/packages/ui/components/combobox/test/lion-combobox.test.js @@ -670,6 +670,25 @@ describe('lion-combobox', () => { expect(el.checkedIndex).to.equal(-1); }); + it('has the correct Overlay Config defined', async () => { + const el = /** @type {LionCombobox} */ ( + await fixture(html` + + Artichoke + Chard + Chicory + Victoria Plum + + `) + ); + // @ts-ignore [allow-protected] in test + expect(el._defineOverlayConfig().elementToFocusAfterHide).to.equal(undefined); + // @ts-ignore [allow-protected] in test + expect(el._defineOverlayConfig().invokerNode).to.equal(el._inputNode); + // @ts-ignore [allow-protected] in test + expect(el._defineOverlayConfig().visibilityTriggerFunction).to.equal(undefined); + }); + // NB: If this becomes a suite, move to separate file describe('Subclassers', () => { it('allows to control overlay visibility via "_showOverlayCondition"', async () => {