mirror of
https://github.com/home-assistant/frontend.git
synced 2025-12-20 10:48:44 +00:00
Fix refresh in energy panel subviews (#28252)
This commit is contained in:
@@ -146,11 +146,15 @@ class PanelEnergy extends LitElement {
|
|||||||
}
|
}
|
||||||
await this._setLovelace();
|
await this._setLovelace();
|
||||||
|
|
||||||
// Navigate to first view if not there yet
|
// Check if current path is valid, navigate to first view if not
|
||||||
const firstPath = this._lovelace!.config?.views?.[0]?.path;
|
const views = this._lovelace!.config?.views || [];
|
||||||
|
const validPaths = views.map((view) => view.path);
|
||||||
const viewPath: string | undefined = this.route!.path.split("/")[1];
|
const viewPath: string | undefined = this.route!.path.split("/")[1];
|
||||||
if (viewPath !== firstPath) {
|
if (!viewPath || !validPaths.includes(viewPath)) {
|
||||||
navigate(`${this.route!.prefix}/${firstPath}`);
|
navigate(`${this.route!.prefix}/${validPaths[0]}`);
|
||||||
|
} else {
|
||||||
|
// Force hui-root to re-process the route by creating a new route object
|
||||||
|
this.route = { ...this.route! };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user