|
| 1 | +import { UmbRefItemElement } from '@umbraco-cms/backoffice/components'; |
1 | 2 | import type { |
2 | 3 | UmbEntityCreateOptionActionListModalData, |
3 | 4 | UmbEntityCreateOptionActionListModalValue, |
@@ -60,20 +61,33 @@ export class UmbEntityCreateOptionActionListModalElement extends UmbModalBaseEle |
60 | 61 | ); |
61 | 62 | } |
62 | 63 |
|
63 | | - async #onClick(event: Event, controller: UmbExtensionApiInitializer<ManifestType>, href?: string) { |
| 64 | + async #onOpen(event: Event, controller: UmbExtensionApiInitializer<ManifestType>) { |
64 | 65 | event.stopPropagation(); |
65 | 66 |
|
66 | | - // skip if href is defined |
67 | | - if (href) { |
68 | | - return; |
| 67 | + if (!controller.api) { |
| 68 | + throw new Error('No API found'); |
69 | 69 | } |
70 | 70 |
|
71 | | - if (!controller.api) throw new Error('No API found'); |
72 | 71 | await controller.api.execute(); |
73 | 72 |
|
74 | 73 | this._submitModal(); |
75 | 74 | } |
76 | 75 |
|
| 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 | + |
77 | 91 | #getTarget(href?: string) { |
78 | 92 | if (href && href.startsWith('http')) { |
79 | 93 | return '_blank'; |
@@ -121,7 +135,8 @@ export class UmbEntityCreateOptionActionListModalElement extends UmbModalBaseEle |
121 | 135 | icon=${manifest.meta.icon} |
122 | 136 | href=${ifDefined(href)} |
123 | 137 | 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)}> |
125 | 140 | </umb-ref-item> |
126 | 141 | `; |
127 | 142 | } |
|
0 commit comments