From d3e2cc9128daac2ee54fdc6e352bf2778b0cd33c Mon Sep 17 00:00:00 2001 From: Ludeeus Date: Sat, 9 Oct 2021 15:38:51 +0000 Subject: [PATCH] Add shouldUpdate --- src/components/ha-alert.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/components/ha-alert.ts b/src/components/ha-alert.ts index c27f9b825e..80be2fb3c8 100644 --- a/src/components/ha-alert.ts +++ b/src/components/ha-alert.ts @@ -7,7 +7,7 @@ import { mdiClose, mdiInformationOutline, } from "@mdi/js"; -import { css, html, LitElement } from "lit"; +import { css, html, LitElement, PropertyValues } from "lit"; import { customElement, property } from "lit/decorators"; import { classMap } from "lit/directives/class-map"; import { fireEvent } from "../common/dom/fire_event"; @@ -47,6 +47,18 @@ class HaAlert extends LitElement { @property({ type: Boolean }) public rtl = false; + protected shouldUpdate(changedProps: PropertyValues): boolean { + if (changedProps.size !== 1 || !changedProps.has("hass")) { + return true; + } + + const oldHass = changedProps.get("hass") as HomeAssistant; + if (!oldHass || !this.hass) { + return false; + } + return this.hass.language !== oldHass.language; + } + public render() { return html`