From e1d85df27c8d3f1864b6e0e7b6ea9cce9c1eff00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Fri, 6 Jan 2023 19:14:49 +0100 Subject: [PATCH] move responsibility for providing menu context --- .../property-action-menu/property-action-menu.context.ts | 7 +++++++ .../property-action-menu/property-action-menu.element.ts | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-actions/shared/property-action-menu/property-action-menu.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-actions/shared/property-action-menu/property-action-menu.context.ts index 1face67dbd..1cfbbac557 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-actions/shared/property-action-menu/property-action-menu.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-actions/shared/property-action-menu/property-action-menu.context.ts @@ -1,9 +1,16 @@ import { Observable, ReplaySubject } from 'rxjs'; +import { UmbContextProviderController } from 'src/core/context-api/provide/context-provider.controller'; +import { UmbControllerHostInterface } from 'src/core/controller/controller-host.mixin'; export class UmbPropertyActionMenuContext { + private _isOpen: ReplaySubject = new ReplaySubject(1); public readonly isOpen: Observable = this._isOpen.asObservable(); + constructor(host: UmbControllerHostInterface) { + new UmbContextProviderController(host, 'umbPropertyActionMenu', this); + } + open() { this._isOpen.next(true); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-actions/shared/property-action-menu/property-action-menu.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-actions/shared/property-action-menu/property-action-menu.element.ts index 8e232f5e76..8c92aa08b9 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-actions/shared/property-action-menu/property-action-menu.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-actions/shared/property-action-menu/property-action-menu.element.ts @@ -53,15 +53,13 @@ export class UmbPropertyActionMenuElement extends UmbLitElement { @state() private _open = false; - private _propertyActionMenuContext = new UmbPropertyActionMenuContext(); + private _propertyActionMenuContext = new UmbPropertyActionMenuContext(this); connectedCallback(): void { super.connectedCallback(); this._observePropertyActions(); this._observePropertyActionMenuOpenState(); - - this.provideContext('umbPropertyActionMenu', this._propertyActionMenuContext); } private _observePropertyActions() {