From b14597d7649613a2c3e2f6cc416bd1a3b0aa1d12 Mon Sep 17 00:00:00 2001 From: Josh Willox Date: Sat, 28 May 2022 17:59:21 +1000 Subject: [PATCH] Fix embedded button placement for 2022.6.0 --- src/entity-row.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/entity-row.ts b/src/entity-row.ts index be3d7862..a34a6ee3 100644 --- a/src/entity-row.ts +++ b/src/entity-row.ts @@ -41,11 +41,20 @@ createModule("hui-generic-entity-row", function () { provideHass(paperButtons); - let el: Element | null | undefined = this.shadowRoot.querySelector("slot"); + let el = this.shadowRoot.querySelector("slot"); if (!el) return; if (el.parentElement) { - if (el.parentElement.classList.contains("text-content")) { + if (el.parentElement.parentElement) { + if ( + el.parentElement.classList.contains("state") && + el.parentElement.parentElement.classList.contains("text-content") + ) { + el = el.parentElement.parentElement; + } else { + console.error("unexpected parent node found"); + } + } else if (el.parentElement.classList.contains("text-content")) { el = el.parentElement; } else { console.error("unexpected parent node found"); @@ -53,12 +62,11 @@ createModule("hui-generic-entity-row", function () { } if (pbConfig.hide_state) { - (el as HTMLElement).style.display = "none"; + el.style.display = "none"; } if (pbConfig.hide_badge) { - const el: HTMLElement | null = - this.shadowRoot.querySelector("state-badge"); + const el = this.shadowRoot.querySelector("state-badge"); if (el) { el.style.visibility = "hidden"; el.style.marginLeft = "-48px";