diff --git a/packages/calcite-components/src/components.d.ts b/packages/calcite-components/src/components.d.ts index 01720732f38..968b29ee985 100644 --- a/packages/calcite-components/src/components.d.ts +++ b/packages/calcite-components/src/components.d.ts @@ -2036,6 +2036,7 @@ export namespace Components { "autocomplete": string; /** * Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726 + * @ignore */ "autofocus": boolean; /** @@ -2380,6 +2381,7 @@ export namespace Components { "autocomplete": string; /** * Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726 + * @ignore */ "autofocus": boolean; /** @@ -2552,6 +2554,7 @@ export namespace Components { "autocomplete": string; /** * Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726 + * @ignore */ "autofocus": boolean; /** @@ -9792,6 +9795,7 @@ declare namespace LocalJSX { "autocomplete"?: string; /** * Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726 + * @ignore */ "autofocus"?: boolean; /** @@ -10149,6 +10153,7 @@ declare namespace LocalJSX { "autocomplete"?: string; /** * Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726 + * @ignore */ "autofocus"?: boolean; /** @@ -10323,6 +10328,7 @@ declare namespace LocalJSX { "autocomplete"?: string; /** * Adds global prop, missing from Stencil's `HTMLElement` type, see https://github.com/ionic-team/stencil/issues/5726 + * @ignore */ "autofocus"?: boolean; /** diff --git a/packages/calcite-components/src/components/combobox/combobox.e2e.ts b/packages/calcite-components/src/components/combobox/combobox.e2e.ts index ada72db2f68..552a8787e56 100644 --- a/packages/calcite-components/src/components/combobox/combobox.e2e.ts +++ b/packages/calcite-components/src/components/combobox/combobox.e2e.ts @@ -15,7 +15,7 @@ import { import { html } from "../../../support/formatting"; import { CSS as ComboboxItemCSS } from "../combobox-item/resources"; import { CSS as XButtonCSS } from "../functional/XButton"; -import { getElementXY, skipAnimations } from "../../tests/utils"; +import { getElementXY, newProgrammaticE2EPage, skipAnimations } from "../../tests/utils"; import { CSS } from "./resources"; const selectionModes = ["single", "single-persist", "ancestors", "multiple"]; @@ -2020,4 +2020,14 @@ describe("calcite-combobox", () => { expect(await combobox.getProperty("open")).toBe(false); }); + + it("does not throw an error when a click emits on connect (#9321)", async () => { + const page = await newProgrammaticE2EPage(); + await page.evaluate(async () => { + const combobox = document.createElement("calcite-combobox"); + document.body.click(); + document.body.append(combobox); + }); + await page.waitForChanges(); + }); }); diff --git a/packages/calcite-components/src/components/combobox/combobox.tsx b/packages/calcite-components/src/components/combobox/combobox.tsx index 78e0b0b1544..3d66f912cd5 100644 --- a/packages/calcite-components/src/components/combobox/combobox.tsx +++ b/packages/calcite-components/src/components/combobox/combobox.tsx @@ -64,8 +64,8 @@ import { updateMessages, } from "../../utils/t9n"; import { Scale, SelectionMode, Status } from "../interfaces"; -import { XButton, CSS as XButtonCSS } from "../functional/XButton"; -import { getIconScale } from "../../utils/component"; +import { CSS as XButtonCSS, XButton } from "../functional/XButton"; +import { componentOnReady, getIconScale } from "../../utils/component"; import { Validation } from "../functional/Validation"; import { ComboboxMessages } from "./assets/combobox/t9n"; import { ComboboxChildElement, SelectionDisplay } from "./interfaces"; @@ -343,16 +343,12 @@ export class Combobox //-------------------------------------------------------------------------- @Listen("click", { target: "document" }) - documentClickHandler(event: PointerEvent): void { - if (this.disabled) { + async documentClickHandler(event: PointerEvent): Promise { + if (this.disabled || event.composedPath().includes(this.el)) { return; } - const composedPath = event.composedPath(); - - if (composedPath.includes(this.el) || composedPath.includes(this.referenceEl)) { - return; - } + await componentOnReady(this.el); if (!this.allowCustomValues && this.textInput.value) { this.clearInputValue();