mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 19:26:36 +00:00
Prevent re-creation of custom panel when content was not changed (#13747)
This commit is contained in:
parent
3083d5b04c
commit
17a11809de
@ -61,7 +61,7 @@ export interface EntityRegistryEntryUpdateParams {
|
|||||||
hidden_by: string | null;
|
hidden_by: string | null;
|
||||||
new_entity_id?: string;
|
new_entity_id?: string;
|
||||||
options_domain?: string;
|
options_domain?: string;
|
||||||
options?: SensorEntityOptions | WeatherEntityOptions;
|
options?: SensorEntityOptions | NumberEntityOptions | WeatherEntityOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const findBatteryEntity = (
|
export const findBatteryEntity = (
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import { PropertyValues, ReactiveElement } from "lit";
|
import { PropertyValues, ReactiveElement } from "lit";
|
||||||
import { property } from "lit/decorators";
|
import { property } from "lit/decorators";
|
||||||
import { navigate, NavigateOptions } from "../../common/navigate";
|
import { navigate, NavigateOptions } from "../../common/navigate";
|
||||||
|
import { deepEqual } from "../../common/util/deep-equal";
|
||||||
import { CustomPanelInfo } from "../../data/panel_custom";
|
import { CustomPanelInfo } from "../../data/panel_custom";
|
||||||
import { HomeAssistant, Route } from "../../types";
|
import { HomeAssistant, Route } from "../../types";
|
||||||
import { createCustomPanelElement } from "../../util/custom-panel/create-custom-panel-element";
|
import { createCustomPanelElement } from "../../util/custom-panel/create-custom-panel-element";
|
||||||
@ -54,12 +55,15 @@ export class HaPanelCustom extends ReactiveElement {
|
|||||||
protected update(changedProps: PropertyValues) {
|
protected update(changedProps: PropertyValues) {
|
||||||
super.update(changedProps);
|
super.update(changedProps);
|
||||||
if (changedProps.has("panel")) {
|
if (changedProps.has("panel")) {
|
||||||
// Clean up old things if we had a panel
|
// Clean up old things if we had a panel and the new one is different.
|
||||||
if (changedProps.get("panel")) {
|
const oldPanel = changedProps.get("panel") as CustomPanelInfo | undefined;
|
||||||
this._cleanupPanel();
|
if (!deepEqual(oldPanel, this.panel)) {
|
||||||
|
if (oldPanel) {
|
||||||
|
this._cleanupPanel();
|
||||||
|
}
|
||||||
|
this._createPanel(this.panel);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
this._createPanel(this.panel);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (!this._setProperties) {
|
if (!this._setProperties) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user