From dacafd3746f044af9aadcc49771228dce290fa1c Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Thu, 23 Mar 2023 13:02:02 +0100 Subject: [PATCH] add state for has children --- .../tree/tree-item-base/tree-item-base.element.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/tree-item-base/tree-item-base.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/tree-item-base/tree-item-base.element.ts index 54f8f9d397..0513801269 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/tree-item-base/tree-item-base.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/tree-item-base/tree-item-base.element.ts @@ -40,6 +40,9 @@ export class UmbTreeItemBaseElement extends UmbLitElement { @state() private _hasActions = false; + @state() + private _hasChildren = false; + #treeItemContext?: UmbTreeItemContextBase; constructor() { @@ -49,7 +52,7 @@ export class UmbTreeItemBaseElement extends UmbLitElement { this.#treeItemContext = instance; if (!this.#treeItemContext) return; // TODO: investigate if we can make an observe decorator - this.observe(this.#treeItemContext.hasChildren, (value) => (this.hasChildren = value)); + this.observe(this.#treeItemContext.hasChildren, (value) => (this._hasChildren = value)); this.observe(this.#treeItemContext.isLoading, (value) => (this._isLoading = value)); this.observe(this.#treeItemContext.isSelectable, (value) => (this._isSelectable = value)); this.observe(this.#treeItemContext.isSelected, (value) => (this._isSelected = value)); @@ -102,7 +105,7 @@ export class UmbTreeItemBaseElement extends UmbLitElement { ?selectable=${this._isSelectable} ?selected=${this._isSelected} .loading=${this._isLoading} - .hasChildren=${this.hasChildren} + .hasChildren=${this._hasChildren} label="${ifDefined(this.item?.name)}" href="${ifDefined(this._href)}"> ${this.#renderIcon()} ${this.#renderActions()} ${this.#renderChildItems()}