mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 11:46:42 +00:00
Always render conditional elements (#5398)
This commit is contained in:
parent
087492fc0b
commit
e1b48dd2a2
@ -30,7 +30,12 @@ class HuiConditionalCard extends HuiConditionalBase implements LovelaceCard {
|
|||||||
throw new Error("No card configured.");
|
throw new Error("No card configured.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._element && this._element.parentElement) {
|
||||||
|
this.removeChild(this._element);
|
||||||
|
}
|
||||||
|
|
||||||
this._element = createCardElement(config.card) as LovelaceCard;
|
this._element = createCardElement(config.card) as LovelaceCard;
|
||||||
|
this.appendChild(this._element);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getCardSize(): number {
|
public getCardSize(): number {
|
||||||
|
@ -30,26 +30,19 @@ export class HuiConditionalBase extends UpdatingElement {
|
|||||||
throw new Error("Conditions are invalid.");
|
throw new Error("Conditions are invalid.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._element && this._element.parentElement) {
|
|
||||||
this.removeChild(this._element);
|
|
||||||
}
|
|
||||||
|
|
||||||
this._config = config;
|
this._config = config;
|
||||||
|
this.style.display = "none";
|
||||||
}
|
}
|
||||||
|
|
||||||
protected update(): void {
|
protected update(): void {
|
||||||
if (!this._element || !this.hass) {
|
if (!this._element || !this.hass || !this._config) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const visible =
|
const visible = checkConditionsMet(this._config.conditions, this.hass);
|
||||||
this._config && checkConditionsMet(this._config.conditions, this.hass);
|
|
||||||
|
|
||||||
if (visible) {
|
if (visible) {
|
||||||
this._element.hass = this.hass;
|
this._element.hass = this.hass;
|
||||||
if (!this._element.parentElement) {
|
|
||||||
this.appendChild(this._element);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.style.setProperty("display", visible ? "" : "none");
|
this.style.setProperty("display", visible ? "" : "none");
|
||||||
|
@ -13,7 +13,12 @@ class HuiConditionalRow extends HuiConditionalBase implements LovelaceRow {
|
|||||||
throw new Error("No row configured.");
|
throw new Error("No row configured.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._element && this._element.parentElement) {
|
||||||
|
this.removeChild(this._element);
|
||||||
|
}
|
||||||
|
|
||||||
this._element = createRowElement(config.row) as LovelaceRow;
|
this._element = createRowElement(config.row) as LovelaceRow;
|
||||||
|
this.appendChild(this._element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user