Skip disconnect of custom panels and iframe panels (#6248)

This commit is contained in:
Paulus Schoutsen 2020-06-26 12:53:36 -07:00 committed by GitHub
parent d8661cf2db
commit e4d55e6842
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,7 @@ import {
STATE_NOT_RUNNING,
STATE_RUNNING,
} from "home-assistant-js-websocket";
import { CustomPanelInfo } from "../data/panel_custom";
const CACHE_URL_PATHS = ["lovelace", "developer-tools"];
const COMPONENTS = {
@ -159,7 +160,17 @@ class PartialPanelResolver extends HassRouterPage {
if (document.hidden) {
this._hiddenTimeout = window.setTimeout(() => {
this._hiddenTimeout = undefined;
if (this.lastChild) {
const curPanel = this.hass.panels[this._currentPage];
if (
this.lastChild &&
// iFrames will lose their state when disconnected
// Do not disconnect any iframe panel
curPanel.component_name !== "iframe" &&
// Do not disconnect any custom panel that embeds into iframe (ie hassio)
(curPanel.component_name !== "custom" ||
!(curPanel.config as CustomPanelInfo).config._panel_custom
.embed_iframe)
) {
this._disconnectedPanel = this.lastChild;
this.removeChild(this.lastChild);
}