Skip to content

Commit

Permalink
Fix embedded button placement for 2022.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jcwillox committed May 28, 2022
1 parent 1867183 commit b14597d
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/entity-row.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,32 @@ createModule("hui-generic-entity-row", function () {

provideHass(paperButtons);

let el: Element | null | undefined = this.shadowRoot.querySelector("slot");
let el = this.shadowRoot.querySelector<HTMLElement>("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");
}
}

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<HTMLElement>("state-badge");
if (el) {
el.style.visibility = "hidden";
el.style.marginLeft = "-48px";
Expand Down

0 comments on commit b14597d

Please sign in to comment.