From aaa025f85eb884347d1320ac7be6fcd21ee01682 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Wed, 15 Jan 2025 16:02:15 +0100 Subject: [PATCH] close modal for create options with links (#17988) --- ...create-option-action-list-modal.element.ts | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/entity-action/common/create/modal/entity-create-option-action-list-modal.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/entity-action/common/create/modal/entity-create-option-action-list-modal.element.ts index fc5eed5435..dceee84e17 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/entity-action/common/create/modal/entity-create-option-action-list-modal.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/entity-action/common/create/modal/entity-create-option-action-list-modal.element.ts @@ -1,3 +1,4 @@ +import { UmbRefItemElement } from '@umbraco-cms/backoffice/components'; import type { UmbEntityCreateOptionActionListModalData, UmbEntityCreateOptionActionListModalValue, @@ -60,16 +61,29 @@ export class UmbEntityCreateOptionActionListModalElement extends UmbModalBaseEle ); } - async #onClick(event: Event, controller: UmbExtensionApiInitializer, href?: string) { + async #onOpen(event: Event, controller: UmbExtensionApiInitializer) { event.stopPropagation(); - // skip if href is defined - if (href) { + if (!controller.api) { + throw new Error('No API found'); + } + + await controller.api.execute(); + + this._submitModal(); + } + + async #onNavigate(event: Event, href: string | undefined) { + const refItemElement = event.composedPath().find((x) => x instanceof UmbRefItemElement) as UmbRefItemElement; + + // ignore click events if they are not on a ref item + if (!refItemElement) { return; } - if (!controller.api) throw new Error('No API found'); - await controller.api.execute(); + if (!href) { + throw new Error('No href found'); + } this._submitModal(); } @@ -121,7 +135,8 @@ export class UmbEntityCreateOptionActionListModalElement extends UmbModalBaseEle icon=${manifest.meta.icon} href=${ifDefined(href)} target=${this.#getTarget(href)} - @open=${(event: Event) => this.#onClick(event, controller, href)}> + @open=${(event: Event) => this.#onOpen(event, controller)} + @click=${(event: Event) => this.#onNavigate(event, href)}> `; }