Skip to content

Commit b019f0f

Browse files
Do not set icon color if the item is selected (#19404)
* Do not set icon color if the item is selected * Added helper method for icon version to render. * Fixed naming of protected helper method. * Move further logic into helper method. --------- Co-authored-by: Andy Butland <[email protected]>
1 parent 7346a14 commit b019f0f

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/Umbraco.Web.UI.Client/src/packages/core/tree/tree-item/tree-item-base/tree-item-element-base.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export abstract class UmbTreeItemElementBase<
7171
private _isSelectable = false;
7272

7373
@state()
74-
private _isSelected = false;
74+
protected _isSelected = false;
7575

7676
@state()
7777
private _hasChildren = false;
@@ -165,10 +165,9 @@ export abstract class UmbTreeItemElementBase<
165165
#renderIcon() {
166166
const icon = this._item?.icon;
167167
const isFolder = this._item?.isFolder;
168-
const iconWithoutColor = icon?.split(' ')[0];
169168

170-
if (icon && iconWithoutColor) {
171-
return html`<umb-icon slot="icon" name="${this._isActive ? iconWithoutColor : icon}"></umb-icon>`;
169+
if (icon) {
170+
return html`<umb-icon slot="icon" name="${this._getIconToRender(icon)}"></umb-icon>`;
172171
}
173172

174173
if (isFolder) {
@@ -178,6 +177,11 @@ export abstract class UmbTreeItemElementBase<
178177
return html`<umb-icon slot="icon" name="icon-circle-dotted"></umb-icon>`;
179178
}
180179

180+
protected _getIconToRender(icon: string) {
181+
const iconWithoutColor = icon.split(' ')[0];
182+
return this._isActive || this._isSelected ? iconWithoutColor : icon;
183+
}
184+
181185
renderLabel() {
182186
return html`<slot name="label" slot="label"></slot>`;
183187
}

src/Umbraco.Web.UI.Client/src/packages/documents/documents/tree/tree-item/document-tree-item.element.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ export class UmbDocumentTreeItemElement extends UmbTreeItemElementBase<
3737

3838
override renderIconContainer() {
3939
const icon = this._icon;
40-
const iconWithoutColor = icon?.split(' ')[0];
4140

4241
return html`
4342
<span id="icon-container" slot="icon" class=${classMap({ draft: this._isDraft })}>
44-
${icon && iconWithoutColor
43+
${icon
4544
? html`
46-
<umb-icon id="icon" slot="icon" name="${this._isActive ? iconWithoutColor : icon}"></umb-icon>
45+
<umb-icon id="icon" slot="icon" name="${this._getIconToRender(icon)}"></umb-icon>
4746
${this.#renderStateIcon()}
4847
`
4948
: nothing}

src/Umbraco.Web.UI.Client/src/packages/media/media/tree/tree-item/media-tree-item.element.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ const elementName = 'umb-media-tree-item';
88
export class UmbMediaTreeItemElement extends UmbTreeItemElementBase<UmbMediaTreeItemModel> {
99
override renderIconContainer() {
1010
const icon = this.item?.mediaType.icon;
11-
const iconWithoutColor = icon?.split(' ')[0];
1211

1312
return html`
1413
<span id="icon-container" slot="icon">
15-
${icon && iconWithoutColor
14+
${icon
1615
? html`
17-
<umb-icon id="icon" slot="icon" name="${this._isActive ? iconWithoutColor : icon}"></umb-icon>
16+
<umb-icon id="icon" slot="icon" name="${this._getIconToRender(icon)}"></umb-icon>
1817
${this.#renderStateIcon()}
1918
`
2019
: nothing}

0 commit comments

Comments
 (0)