Skip to content

Commit

Permalink
Fix opaque response caused by object assign of style
Browse files Browse the repository at this point in the history
  • Loading branch information
steverep committed Sep 19, 2023
1 parent dfa1a75 commit 39cf591
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
10 changes: 4 additions & 6 deletions src/components/entity/state-badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ export class StateBadge extends LitElement {
const stateObj = this.stateObj;

const iconStyle: { [name: string]: string } = {};
const hostStyle: Partial<CSSStyleDeclaration> = {
backgroundImage: "",
};
let backgroundImage = "";

this._showIcon = true;

Expand All @@ -134,7 +132,7 @@ export class StateBadge extends LitElement {
if (computeDomain(stateObj.entity_id) === "camera") {
imageUrl = cameraUrlWithWidthHeight(imageUrl, 80, 80);
}
hostStyle.backgroundImage = `url(${imageUrl})`;
backgroundImage = `url(${imageUrl})`;
this._showIcon = false;
} else if (this.color) {
// Externally provided overriding color wins over state color
Expand Down Expand Up @@ -175,12 +173,12 @@ export class StateBadge extends LitElement {
if (this.hass) {
imageUrl = this.hass.hassUrl(imageUrl);
}
hostStyle.backgroundImage = `url(${imageUrl})`;
backgroundImage = `url(${imageUrl})`;
this._showIcon = false;
}

this._iconStyle = iconStyle;
Object.assign(this.style, hostStyle);
this.style.backgroundImage = backgroundImage;
}

static get styles(): CSSResultGroup {
Expand Down
13 changes: 9 additions & 4 deletions src/panels/config/dashboard/ha-config-updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import "@material/mwc-list/mwc-list";
import { UnsubscribeFunc } from "home-assistant-js-websocket";
import { css, CSSResultGroup, html, LitElement, nothing } from "lit";
import { customElement, property } from "lit/decorators";
import { ifDefined } from "lit/directives/if-defined";
import memoizeOne from "memoize-one";
import { fireEvent } from "../../../common/dom/fire_event";
import "../../../components/entity/state-badge";
Expand Down Expand Up @@ -87,7 +88,9 @@ class HaConfigUpdates extends SubscribeMixin(LitElement) {
<ha-list-item
twoline
graphic="avatar"
class=${entity.attributes.skipped_version ? "skipped" : ""}
class=${ifDefined(
entity.attributes.skipped_version ? "skipped" : undefined
)}
.entity_id=${entity.entity_id}
.hasMeta=${!this.narrow}
@click=${this._openMoreInfo}
Expand All @@ -97,9 +100,11 @@ class HaConfigUpdates extends SubscribeMixin(LitElement) {
.title=${entity.attributes.title ||
entity.attributes.friendly_name}
.stateObj=${entity}
class=${this.narrow && entity.attributes.in_progress
? "updating"
: ""}
class=${ifDefined(
this.narrow && entity.attributes.in_progress
? "updating"
: undefined
)}
></state-badge>
${this.narrow && entity.attributes.in_progress
? html`<ha-circular-progress
Expand Down

0 comments on commit 39cf591

Please sign in to comment.