mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix closing notification drawer (#16769)
This commit is contained in:
parent
6c684fd8ee
commit
1bf03f020e
@ -1,7 +1,7 @@
|
|||||||
import "@material/mwc-button";
|
import "@material/mwc-button";
|
||||||
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
import { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||||
import { LitElement, html, css, nothing } from "lit";
|
import { LitElement, html, css, nothing } from "lit";
|
||||||
import { customElement, property, state } from "lit/decorators";
|
import { customElement, property, query, state } from "lit/decorators";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { computeDomain } from "../../common/entity/compute_domain";
|
import { computeDomain } from "../../common/entity/compute_domain";
|
||||||
import "../../components/ha-icon-button-prev";
|
import "../../components/ha-icon-button-prev";
|
||||||
@ -13,6 +13,7 @@ import { HomeAssistant } from "../../types";
|
|||||||
import "./notification-item";
|
import "./notification-item";
|
||||||
import "../../components/ha-header-bar";
|
import "../../components/ha-header-bar";
|
||||||
import "../../components/ha-drawer";
|
import "../../components/ha-drawer";
|
||||||
|
import type { HaDrawer } from "../../components/ha-drawer";
|
||||||
|
|
||||||
@customElement("notification-drawer")
|
@customElement("notification-drawer")
|
||||||
export class HuiNotificationDrawer extends LitElement {
|
export class HuiNotificationDrawer extends LitElement {
|
||||||
@ -22,6 +23,8 @@ export class HuiNotificationDrawer extends LitElement {
|
|||||||
|
|
||||||
@state() private _open = false;
|
@state() private _open = false;
|
||||||
|
|
||||||
|
@query("ha-drawer") private _drawer?: HaDrawer;
|
||||||
|
|
||||||
private _unsubNotifications?: UnsubscribeFunc;
|
private _unsubNotifications?: UnsubscribeFunc;
|
||||||
|
|
||||||
connectedCallback() {
|
connectedCallback() {
|
||||||
@ -53,12 +56,14 @@ export class HuiNotificationDrawer extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
closeDialog = () => {
|
closeDialog = () => {
|
||||||
|
if (this._drawer) {
|
||||||
|
this._drawer.open = false;
|
||||||
|
}
|
||||||
if (this._unsubNotifications) {
|
if (this._unsubNotifications) {
|
||||||
this._unsubNotifications();
|
this._unsubNotifications();
|
||||||
this._unsubNotifications = undefined;
|
this._unsubNotifications = undefined;
|
||||||
}
|
}
|
||||||
this._notifications = [];
|
this._notifications = [];
|
||||||
this._open = false;
|
|
||||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -87,11 +92,7 @@ export class HuiNotificationDrawer extends LitElement {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<ha-drawer
|
<ha-drawer type="modal" open @MDCDrawer:closed=${this._dialogClosed}>
|
||||||
type="modal"
|
|
||||||
.open=${this._open}
|
|
||||||
@MDCDrawer:closed=${this._closeDrawer}
|
|
||||||
>
|
|
||||||
<ha-header-bar>
|
<ha-header-bar>
|
||||||
<div slot="title">
|
<div slot="title">
|
||||||
${this.hass.localize("ui.notification_drawer.title")}
|
${this.hass.localize("ui.notification_drawer.title")}
|
||||||
@ -99,7 +100,7 @@ export class HuiNotificationDrawer extends LitElement {
|
|||||||
<ha-icon-button-prev
|
<ha-icon-button-prev
|
||||||
slot="actionItems"
|
slot="actionItems"
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
@click=${this._closeDrawer}
|
@click=${this.closeDialog}
|
||||||
.label=${this.hass.localize("ui.notification_drawer.close")}
|
.label=${this.hass.localize("ui.notification_drawer.close")}
|
||||||
>
|
>
|
||||||
</ha-icon-button-prev>
|
</ha-icon-button-prev>
|
||||||
@ -132,9 +133,9 @@ export class HuiNotificationDrawer extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _closeDrawer(ev) {
|
private _dialogClosed(ev: Event) {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
this.closeDialog();
|
this._open = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _dismissAll() {
|
private _dismissAll() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user