diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts index 3b754584e3..5e09023145 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/workspace/document-workspace.context.ts @@ -141,13 +141,23 @@ export class UmbDocumentWorkspaceContext async load(unique: string) { this.resetState(); this.#getDataPromise = this.repository.requestByUnique(unique); - const { data } = await this.#getDataPromise; - if (!data) return undefined; + type GetDataType = Awaited>; + const { data, asObservable } = (await this.#getDataPromise) as GetDataType; - this.setIsNew(false); - this.#persistedData.setValue(data); - this.#currentData.setValue(data); - return data || undefined; + if (data) { + this.setIsNew(false); + this.#persistedData.update(data); + this.#currentData.update(data); + } + + this.observe(asObservable(), (entity) => this.#onStoreChange(entity), 'umbDocumentStoreObserver'); + } + + #onStoreChange(entity: EntityType | undefined) { + if (!entity) { + //TODO: This solution is alright for now. But reconsider when we introduce signal-r + history.pushState(null, '', 'section/content'); + } } async create(parent: { entityType: string; unique: string | null }, documentTypeUnique: string) {