From 1bf03f020e2b2523081d4f03580886b51e970c72 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Mon, 5 Jun 2023 14:26:51 +0200 Subject: [PATCH] Fix closing notification drawer (#16769) --- .../notifications/notification-drawer.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/dialogs/notifications/notification-drawer.ts b/src/dialogs/notifications/notification-drawer.ts index ccbb0b2533..5b4eacb27e 100644 --- a/src/dialogs/notifications/notification-drawer.ts +++ b/src/dialogs/notifications/notification-drawer.ts @@ -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` - +
${this.hass.localize("ui.notification_drawer.title")} @@ -99,7 +100,7 @@ export class HuiNotificationDrawer extends LitElement { @@ -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() {