Merge pull request #1775 from umbraco/bugfix/collection-context-loading

Bugfix/collection context loading
This commit is contained in:
Mads Rasmussen
2024-05-07 10:55:29 +02:00
committed by GitHub
2 changed files with 3 additions and 26 deletions

View File

@@ -1,29 +1,10 @@
import type { UmbDefaultCollectionContext } from '../default/collection-default.context.js';
import { UMB_COLLECTION_CONTEXT } from '../default/collection-default.context.js';
import { html, customElement, state, nothing } from '@umbraco-cms/backoffice/external/lit';
import { html, customElement } from '@umbraco-cms/backoffice/external/lit';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
@customElement('umb-collection-action-bundle')
export class UmbCollectionActionBundleElement extends UmbLitElement {
#collectionContext?: UmbDefaultCollectionContext<any, any>;
@state()
_collectionAlias? = '';
constructor() {
super();
this.consumeContext(UMB_COLLECTION_CONTEXT, (context) => {
this.#collectionContext = context;
if (!this.#collectionContext) return;
this._collectionAlias = this.#collectionContext.getManifest()?.alias;
});
}
render() {
return html`
${this._collectionAlias ? html`<umb-extension-slot type="collectionAction"></umb-extension-slot>` : nothing}
`;
return html`<umb-extension-slot type="collectionAction"></umb-extension-slot>`;
}
}

View File

@@ -32,15 +32,11 @@ export class UmbCollectionDefaultElement extends UmbLitElement {
super();
this.consumeContext(UMB_COLLECTION_CONTEXT, (context) => {
this.#collectionContext = context;
this.#collectionContext?.requestCollection();
this.#observeCollectionRoutes();
});
}
protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void {
super.firstUpdated(_changedProperties);
this.#collectionContext?.requestCollection();
}
#observeCollectionRoutes() {
if (!this.#collectionContext) return;