From cd740ed1355a601561805eed231c7a38282bb547 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 24 Feb 2022 02:52:12 -0800 Subject: [PATCH] Fix cast receiver background (#11825) Co-authored-by: Bram Kragten --- cast/src/receiver/layout/hc-lovelace.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/cast/src/receiver/layout/hc-lovelace.ts b/cast/src/receiver/layout/hc-lovelace.ts index 3cb24f24cf..7ccebc9c7b 100644 --- a/cast/src/receiver/layout/hc-lovelace.ts +++ b/cast/src/receiver/layout/hc-lovelace.ts @@ -1,5 +1,5 @@ import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; -import { customElement, property } from "lit/decorators"; +import { customElement, property, query } from "lit/decorators"; import { fireEvent } from "../../../../src/common/dom/fire_event"; import { LovelaceConfig } from "../../../../src/data/lovelace"; import { Lovelace } from "../../../../src/panels/lovelace/types"; @@ -20,6 +20,8 @@ class HcLovelace extends LitElement { @property() public urlPath: string | null = null; + @query("hui-view") private _huiView?: HTMLElement; + protected render(): TemplateResult { const index = this._viewIndex; if (index === undefined) { @@ -78,12 +80,12 @@ class HcLovelace extends LitElement { this.lovelaceConfig.background; if (configBackground) { - (this.shadowRoot!.querySelector( - "hui-view" - ) as HTMLElement)!.style.setProperty( + this._huiView!.style.setProperty( "--lovelace-background", configBackground ); + } else { + this._huiView!.style.removeProperty("--lovelace-background"); } } } @@ -116,6 +118,9 @@ class HcLovelace extends LitElement { :host > * { flex: 1; } + hui-view { + background: var(--lovelace-background, var(--primary-background-color)); + } `; } }