mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-28 03:36:44 +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.");
|
||||
}
|
||||
|
||||
if (this._element && this._element.parentElement) {
|
||||
this.removeChild(this._element);
|
||||
}
|
||||
|
||||
this._element = createCardElement(config.card) as LovelaceCard;
|
||||
this.appendChild(this._element);
|
||||
}
|
||||
|
||||
public getCardSize(): number {
|
||||
|
@ -30,26 +30,19 @@ export class HuiConditionalBase extends UpdatingElement {
|
||||
throw new Error("Conditions are invalid.");
|
||||
}
|
||||
|
||||
if (this._element && this._element.parentElement) {
|
||||
this.removeChild(this._element);
|
||||
}
|
||||
|
||||
this._config = config;
|
||||
this.style.display = "none";
|
||||
}
|
||||
|
||||
protected update(): void {
|
||||
if (!this._element || !this.hass) {
|
||||
if (!this._element || !this.hass || !this._config) {
|
||||
return;
|
||||
}
|
||||
|
||||
const visible =
|
||||
this._config && checkConditionsMet(this._config.conditions, this.hass);
|
||||
const visible = checkConditionsMet(this._config.conditions, this.hass);
|
||||
|
||||
if (visible) {
|
||||
this._element.hass = this.hass;
|
||||
if (!this._element.parentElement) {
|
||||
this.appendChild(this._element);
|
||||
}
|
||||
}
|
||||
|
||||
this.style.setProperty("display", visible ? "" : "none");
|
||||
|
@ -13,7 +13,12 @@ class HuiConditionalRow extends HuiConditionalBase implements LovelaceRow {
|
||||
throw new Error("No row configured.");
|
||||
}
|
||||
|
||||
if (this._element && this._element.parentElement) {
|
||||
this.removeChild(this._element);
|
||||
}
|
||||
|
||||
this._element = createRowElement(config.row) as LovelaceRow;
|
||||
this.appendChild(this._element);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user