mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +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 { UnsubscribeFunc } from "home-assistant-js-websocket";
|
||||
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 { computeDomain } from "../../common/entity/compute_domain";
|
||||
import "../../components/ha-icon-button-prev";
|
||||
@ -13,6 +13,7 @@ import { HomeAssistant } from "../../types";
|
||||
import "./notification-item";
|
||||
import "../../components/ha-header-bar";
|
||||
import "../../components/ha-drawer";
|
||||
import type { HaDrawer } from "../../components/ha-drawer";
|
||||
|
||||
@customElement("notification-drawer")
|
||||
export class HuiNotificationDrawer extends LitElement {
|
||||
@ -22,6 +23,8 @@ export class HuiNotificationDrawer extends LitElement {
|
||||
|
||||
@state() private _open = false;
|
||||
|
||||
@query("ha-drawer") private _drawer?: HaDrawer;
|
||||
|
||||
private _unsubNotifications?: UnsubscribeFunc;
|
||||
|
||||
connectedCallback() {
|
||||
@ -53,12 +56,14 @@ export class HuiNotificationDrawer extends LitElement {
|
||||
}
|
||||
|
||||
closeDialog = () => {
|
||||
if (this._drawer) {
|
||||
this._drawer.open = false;
|
||||
}
|
||||
if (this._unsubNotifications) {
|
||||
this._unsubNotifications();
|
||||
this._unsubNotifications = undefined;
|
||||
}
|
||||
this._notifications = [];
|
||||
this._open = false;
|
||||
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||
};
|
||||
|
||||
@ -87,11 +92,7 @@ export class HuiNotificationDrawer extends LitElement {
|
||||
});
|
||||
|
||||
return html`
|
||||
<ha-drawer
|
||||
type="modal"
|
||||
.open=${this._open}
|
||||
@MDCDrawer:closed=${this._closeDrawer}
|
||||
>
|
||||
<ha-drawer type="modal" open @MDCDrawer:closed=${this._dialogClosed}>
|
||||
<ha-header-bar>
|
||||
<div slot="title">
|
||||
${this.hass.localize("ui.notification_drawer.title")}
|
||||
@ -99,7 +100,7 @@ export class HuiNotificationDrawer extends LitElement {
|
||||
<ha-icon-button-prev
|
||||
slot="actionItems"
|
||||
.hass=${this.hass}
|
||||
@click=${this._closeDrawer}
|
||||
@click=${this.closeDialog}
|
||||
.label=${this.hass.localize("ui.notification_drawer.close")}
|
||||
>
|
||||
</ha-icon-button-prev>
|
||||
@ -132,9 +133,9 @@ export class HuiNotificationDrawer extends LitElement {
|
||||
`;
|
||||
}
|
||||
|
||||
private _closeDrawer(ev) {
|
||||
private _dialogClosed(ev: Event) {
|
||||
ev.stopPropagation();
|
||||
this.closeDialog();
|
||||
this._open = false;
|
||||
}
|
||||
|
||||
private _dismissAll() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user