Skip to content

Commit aaa025f

Browse files
close modal for create options with links (#17988)
1 parent a29f510 commit aaa025f

File tree

1 file changed

+21
-6
lines changed

1 file changed

+21
-6
lines changed

src/Umbraco.Web.UI.Client/src/packages/core/entity-action/common/create/modal/entity-create-option-action-list-modal.element.ts

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { UmbRefItemElement } from '@umbraco-cms/backoffice/components';
12
import type {
23
UmbEntityCreateOptionActionListModalData,
34
UmbEntityCreateOptionActionListModalValue,
@@ -60,20 +61,33 @@ export class UmbEntityCreateOptionActionListModalElement extends UmbModalBaseEle
6061
);
6162
}
6263

63-
async #onClick(event: Event, controller: UmbExtensionApiInitializer<ManifestType>, href?: string) {
64+
async #onOpen(event: Event, controller: UmbExtensionApiInitializer<ManifestType>) {
6465
event.stopPropagation();
6566

66-
// skip if href is defined
67-
if (href) {
68-
return;
67+
if (!controller.api) {
68+
throw new Error('No API found');
6969
}
7070

71-
if (!controller.api) throw new Error('No API found');
7271
await controller.api.execute();
7372

7473
this._submitModal();
7574
}
7675

76+
async #onNavigate(event: Event, href: string | undefined) {
77+
const refItemElement = event.composedPath().find((x) => x instanceof UmbRefItemElement) as UmbRefItemElement;
78+
79+
// ignore click events if they are not on a ref item
80+
if (!refItemElement) {
81+
return;
82+
}
83+
84+
if (!href) {
85+
throw new Error('No href found');
86+
}
87+
88+
this._submitModal();
89+
}
90+
7791
#getTarget(href?: string) {
7892
if (href && href.startsWith('http')) {
7993
return '_blank';
@@ -121,7 +135,8 @@ export class UmbEntityCreateOptionActionListModalElement extends UmbModalBaseEle
121135
icon=${manifest.meta.icon}
122136
href=${ifDefined(href)}
123137
target=${this.#getTarget(href)}
124-
@open=${(event: Event) => this.#onClick(event, controller, href)}>
138+
@open=${(event: Event) => this.#onOpen(event, controller)}
139+
@click=${(event: Event) => this.#onNavigate(event, href)}>
125140
</umb-ref-item>
126141
`;
127142
}

0 commit comments

Comments
 (0)