mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +00:00
Cleanup iron resize event (#18813)
This commit is contained in:
parent
b5b2392dd2
commit
843430ef41
@ -17,7 +17,7 @@ class HaFaded extends LitElement {
|
|||||||
@click=${this._showContent}
|
@click=${this._showContent}
|
||||||
>
|
>
|
||||||
<slot
|
<slot
|
||||||
@iron-resize=${
|
@content-resize=${
|
||||||
// ha-markdown-element fire this when render is complete
|
// ha-markdown-element fire this when render is complete
|
||||||
this._setShowContent
|
this._setShowContent
|
||||||
}
|
}
|
||||||
@ -79,4 +79,7 @@ declare global {
|
|||||||
interface HTMLElementTagNameMap {
|
interface HTMLElementTagNameMap {
|
||||||
"ha-faded": HaFaded;
|
"ha-faded": HaFaded;
|
||||||
}
|
}
|
||||||
|
interface HASSDomEvents {
|
||||||
|
"content-resize": undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ class HaMarkdownElement extends ReactiveElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _resize = () => fireEvent(this, "iron-resize");
|
private _resize = () => fireEvent(this, "content-resize");
|
||||||
}
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
@ -6,16 +6,8 @@ import {
|
|||||||
mdiTuneVariant,
|
mdiTuneVariant,
|
||||||
mdiWaterPercent,
|
mdiWaterPercent,
|
||||||
} from "@mdi/js";
|
} from "@mdi/js";
|
||||||
import {
|
import { CSSResultGroup, LitElement, css, html, nothing } from "lit";
|
||||||
CSSResultGroup,
|
|
||||||
LitElement,
|
|
||||||
PropertyValues,
|
|
||||||
css,
|
|
||||||
html,
|
|
||||||
nothing,
|
|
||||||
} from "lit";
|
|
||||||
import { property, state } from "lit/decorators";
|
import { property, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
|
||||||
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
||||||
import { supportsFeature } from "../../../common/entity/supports-feature";
|
import { supportsFeature } from "../../../common/entity/supports-feature";
|
||||||
import "../../../components/ha-control-select-menu";
|
import "../../../components/ha-control-select-menu";
|
||||||
@ -50,8 +42,6 @@ class MoreInfoClimate extends LitElement {
|
|||||||
|
|
||||||
@state() private _mainControl: MainControl = "temperature";
|
@state() private _mainControl: MainControl = "temperature";
|
||||||
|
|
||||||
private _resizeDebounce?: number;
|
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
if (!this.stateObj) {
|
if (!this.stateObj) {
|
||||||
return nothing;
|
return nothing;
|
||||||
@ -293,21 +283,6 @@ class MoreInfoClimate extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected updated(changedProps: PropertyValues) {
|
|
||||||
super.updated(changedProps);
|
|
||||||
if (!changedProps.has("stateObj") || !this.stateObj) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._resizeDebounce) {
|
|
||||||
clearTimeout(this._resizeDebounce);
|
|
||||||
}
|
|
||||||
this._resizeDebounce = window.setTimeout(() => {
|
|
||||||
fireEvent(this, "iron-resize");
|
|
||||||
this._resizeDebounce = undefined;
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
|
|
||||||
private _setMainControl(ev: any) {
|
private _setMainControl(ev: any) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
this._mainControl = ev.currentTarget.control;
|
this._mainControl = ev.currentTarget.control;
|
||||||
|
@ -8,7 +8,6 @@ import {
|
|||||||
nothing,
|
nothing,
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { property, state } from "lit/decorators";
|
import { property, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../../../common/dom/fire_event";
|
|
||||||
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
import { stopPropagation } from "../../../common/dom/stop_propagation";
|
||||||
import { supportsFeature } from "../../../common/entity/supports-feature";
|
import { supportsFeature } from "../../../common/entity/supports-feature";
|
||||||
import "../../../components/ha-control-select-menu";
|
import "../../../components/ha-control-select-menu";
|
||||||
@ -38,8 +37,6 @@ class MoreInfoHumidifier extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _resizeDebounce?: number;
|
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
if (!this.stateObj) {
|
if (!this.stateObj) {
|
||||||
return nothing;
|
return nothing;
|
||||||
@ -135,21 +132,6 @@ class MoreInfoHumidifier extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected updated(changedProps: PropertyValues) {
|
|
||||||
super.updated(changedProps);
|
|
||||||
if (!changedProps.has("stateObj") || !this.stateObj) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this._resizeDebounce) {
|
|
||||||
clearTimeout(this._resizeDebounce);
|
|
||||||
}
|
|
||||||
this._resizeDebounce = window.setTimeout(() => {
|
|
||||||
fireEvent(this, "iron-resize");
|
|
||||||
this._resizeDebounce = undefined;
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
|
|
||||||
private _handleStateChanged(ev) {
|
private _handleStateChanged(ev) {
|
||||||
const newVal = ev.target.value || null;
|
const newVal = ev.target.value || null;
|
||||||
this._callServiceHelper(
|
this._callServiceHelper(
|
||||||
|
@ -55,7 +55,6 @@ export class HuiViewVisibilityEditor extends LitElement {
|
|||||||
|
|
||||||
fetchUsers(this.hass).then((users) => {
|
fetchUsers(this.hass).then((users) => {
|
||||||
this._users = users.filter((user) => !user.system_generated);
|
this._users = users.filter((user) => !user.system_generated);
|
||||||
fireEvent(this, "iron-resize");
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -655,8 +655,6 @@ class HUIRoot extends LitElement {
|
|||||||
if (!oldLovelace || oldLovelace.editMode !== this.lovelace!.editMode) {
|
if (!oldLovelace || oldLovelace.editMode !== this.lovelace!.editMode) {
|
||||||
const views = this.config && this.config.views;
|
const views = this.config && this.config.views;
|
||||||
|
|
||||||
fireEvent(this, "iron-resize");
|
|
||||||
|
|
||||||
// Leave unused entities when leaving edit mode
|
// Leave unused entities when leaving edit mode
|
||||||
if (
|
if (
|
||||||
this.lovelace!.mode === "storage" &&
|
this.lovelace!.mode === "storage" &&
|
||||||
@ -980,8 +978,6 @@ class HUIRoot extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
root.appendChild(view);
|
root.appendChild(view);
|
||||||
// Recalculate to see if we need to adjust content area for tab bar
|
|
||||||
fireEvent(this, "iron-resize");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultGroup {
|
static get styles(): CSSResultGroup {
|
||||||
|
@ -64,11 +64,6 @@ export class MasonryView extends LitElement implements LovelaceViewElement {
|
|||||||
|
|
||||||
private _mqlListenerRef?: () => void;
|
private _mqlListenerRef?: () => void;
|
||||||
|
|
||||||
public constructor() {
|
|
||||||
super();
|
|
||||||
this.addEventListener("iron-resize", (ev: Event) => ev.stopPropagation());
|
|
||||||
}
|
|
||||||
|
|
||||||
public connectedCallback() {
|
public connectedCallback() {
|
||||||
super.connectedCallback();
|
super.connectedCallback();
|
||||||
this._initMqls();
|
this._initMqls();
|
||||||
|
@ -49,7 +49,6 @@ declare global {
|
|||||||
};
|
};
|
||||||
change: undefined;
|
change: undefined;
|
||||||
"hass-logout": undefined;
|
"hass-logout": undefined;
|
||||||
"iron-resize": undefined;
|
|
||||||
"config-refresh": undefined;
|
"config-refresh": undefined;
|
||||||
"hass-api-called": {
|
"hass-api-called": {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user