diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/components/entity-actions-bundle/entity-actions-bundle.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/components/entity-actions-bundle/entity-actions-bundle.element.ts index 98b3c13bea..71090ba875 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/components/entity-actions-bundle/entity-actions-bundle.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/components/entity-actions-bundle/entity-actions-bundle.element.ts @@ -75,7 +75,11 @@ export class UmbEntityActionsBundleElement extends UmbLitElement { #openContextMenu() { if (!this.entityType) throw new Error('Entity type is not defined'); if (this.unique === undefined) throw new Error('Unique is not defined'); - this.#sectionSidebarContext?.toggleContextMenu(this.entityType, this.unique, this.label); + this.#sectionSidebarContext?.toggleContextMenu(this, { + entityType: this.entityType, + unique: this.unique, + headline: this.label, + }); } async #onFirstActionClick(event: PointerEvent) { diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/section/section-sidebar-context-menu/section-sidebar-context-menu.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/section/section-sidebar-context-menu/section-sidebar-context-menu.element.ts index b17d9635c8..c1cdbe7762 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/section/section-sidebar-context-menu/section-sidebar-context-menu.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/section/section-sidebar-context-menu/section-sidebar-context-menu.element.ts @@ -4,6 +4,8 @@ import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; import { css, html, nothing, customElement, state } from '@umbraco-cms/backoffice/external/lit'; import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; import { observeMultiple } from '@umbraco-cms/backoffice/observable-api'; +import type { UmbContextRequestEvent } from '@umbraco-cms/backoffice/context-api'; +import { UMB_CONTENT_REQUEST_EVENT_TYPE } from '@umbraco-cms/backoffice/context-api'; @customElement('umb-section-sidebar-context-menu') export class UmbSectionSidebarContextMenuElement extends UmbLitElement { @@ -66,6 +68,17 @@ export class UmbSectionSidebarContextMenuElement extends UmbLitElement { this.#closeContextMenu(); } + #proxyContextRequests(event: UmbContextRequestEvent) { + if (!this.#sectionSidebarContext) return; + // Note for this hack (The if-sentence): [NL] + // We do not currently have a good enough control to ensure that the proxy is last, meaning if another context is provided at this element, it might respond after the proxy event has been dispatched. + // To avoid such this hack just prevents proxying the event if its a request for its own context. + if (event.contextAlias !== UMB_SECTION_SIDEBAR_CONTEXT.contextAlias) { + event.stopImmediatePropagation(); + this.#sectionSidebarContext.getContextElement()?.dispatchEvent(event.clone()); + } + } + render() { return html` ${this.#renderBackdrop()} @@ -84,7 +97,7 @@ export class UmbSectionSidebarContextMenuElement extends UmbLitElement { #renderModal() { return this._isOpen && this._unique !== undefined && this._entityType - ? html`
+ ? html`
${this._headline ? html`

${this.localize.string(this._headline)}

` : nothing} (undefined); headline = this.#headline.asObservable(); + #contextElement: Element | undefined = undefined; + constructor(host: UmbControllerHost) { super(host, UMB_SECTION_SIDEBAR_CONTEXT); } - toggleContextMenu(entityType: string, unique: string | null | undefined, headline: string | undefined) { - this.openContextMenu(entityType, unique, headline); + toggleContextMenu(host: Element, args: UmbOpenContextMenuArgs) { + this.openContextMenu(host, args); } // TODO: we wont get notified about tree item name changes because we don't have a subscription // we need to figure out how we best can handle this when we only know the entity and unique id - openContextMenu(entityType: string, unique: string | null | undefined, headline: string | undefined) { - this.#entityType.setValue(entityType); - this.#unique.setValue(unique); - this.#headline.setValue(headline); + openContextMenu(host: Element, args: UmbOpenContextMenuArgs) { + this.#entityType.setValue(args.entityType); + this.#unique.setValue(args.unique); + this.#headline.setValue(args.headline); this.#contextMenuIsOpen.setValue(true); + this.#contextElement = host; } closeContextMenu() { @@ -38,6 +42,11 @@ export class UmbSectionSidebarContext extends UmbContextBase { // Only include Property Editor UIs which has Property Editor Schema Alias this._propertyEditorUIs = propertyEditorUIs.filter(