diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/modal/modal-context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/modal/modal-context.ts index d03d249131..1dd7e5ec9b 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/modal/modal-context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/modal/modal-context.ts @@ -55,6 +55,7 @@ export class UmbModalContextClass { @@ -105,7 +106,7 @@ export class UmbModalContextClass { - return this.#submitPromise; - } - /* TODO: modals being part of the extension registry now means that a modal element can change over time. It makes this code a bit more complex. The main idea is to have the element as part of the modalHandler so it is possible to dispatch events from within the modal element to the one that opened it. Now when the element is an observable it makes it more complex because this host needs to subscribe to updates to the element, instead of just having a reference to it. If we find a better generic solution to communicate between the modal and the implementor, then we can remove the element as part of the modalHandler. */ - #observeModal(modalAlias: string, data?: ModalData) { + #observeModal(modalAlias: string) { if (this.#host) { new UmbObserverController( this.#host, @@ -172,7 +145,7 @@ export class UmbModalContextClass { this.#removeInnerElement(); if (manifest) { - const innerElement = await this.#createInnerElement(manifest, data); + const innerElement = await this.#createInnerElement(manifest); if (innerElement) { this.#appendInnerElement(innerElement); } @@ -183,6 +156,20 @@ export class UmbModalContextClass { + return this.#submitPromise; + } } export const UMB_MODAL_CONTEXT_TOKEN = new UmbContextToken('UmbModalContext'); diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/modal/modal-manager.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/modal/modal-manager.context.ts index 9462c0bca6..18b222e88b 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/modal/modal-manager.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/modal/modal-manager.context.ts @@ -1,5 +1,5 @@ -import { UmbModalContext, UmbModalContextClass } from './modal-context.js'; import type { UmbModalToken } from './token/modal-token.js'; +import { UmbModalContext, UmbModalContextClass } from './index.js'; import type { IRouterSlot } from '@umbraco-cms/backoffice/external/router-slot'; import type { UUIModalSidebarSize } from '@umbraco-cms/backoffice/external/uui'; import { BehaviorSubject } from '@umbraco-cms/backoffice/external/rxjs'; @@ -28,10 +28,12 @@ export class UmbModalManagerContext { /** * Opens a modal or sidebar modal * @public - * @param {(string | HTMLElement)} element - * @param {UmbModalOptions} [options] + * @param {(string | UmbModalToken)} modalAlias + * @param {ModalData} data + * @param {UmbModalConfig} config + * @param {IRouterSlot | null} router * @return {*} {UmbModalHandler} - * @memberof UmbModalContext + * @memberof UmbModalManagerContext */ public open( modalAlias: string | UmbModalToken, @@ -59,10 +61,9 @@ export class UmbModalManagerContext { * Closes a modal or sidebar modal * @private * @param {string} key - * @memberof UmbModalContext + * @memberof UmbModalManagerContext */ public close(key: string) { - console.log('close', key, this.#modals); const modal = this.#modals.getValue().find((modal) => modal.key === key); if (modal) { modal.reject(); @@ -76,12 +77,12 @@ export class UmbModalManagerContext { /** * Handles the close-end event * @private - * @param {UmbModalContext} modalHandler - * @memberof UmbModalContext + * @param {UmbModalContext} modalContext + * @memberof UmbModalManagerContext */ - #onCloseEnd(modalHandler: UmbModalContext) { - modalHandler.modalElement.removeEventListener('close-end', () => this.#onCloseEnd(modalHandler)); - this.#remove(modalHandler.key); + #onCloseEnd(modalContext: UmbModalContext) { + modalContext.modalElement.removeEventListener('close-end', () => this.#onCloseEnd(modalContext)); + this.#remove(modalContext.key); } }