diff --git a/src/dialogs/notifications/notification-drawer.js b/src/dialogs/notifications/notification-drawer.js index 927af2f3a9..3b7c5c54da 100644 --- a/src/dialogs/notifications/notification-drawer.js +++ b/src/dialogs/notifications/notification-drawer.js @@ -88,6 +88,7 @@ export class HuiNotificationDrawer extends EventsMixin( notifications: { type: Array, computed: "_computeNotifications(open, hass, _notificationsBackend)", + observer: "_notificationsChanged", }, _notificationsBackend: { type: Array, @@ -130,6 +131,17 @@ export class HuiNotificationDrawer extends EventsMixin( } } + _notificationsChanged(newNotifications, oldNotifications) { + // automatically close drawer when last notification has been dismissed + if ( + this.open && + oldNotifications.length > 0 && + !newNotifications.length === 0 + ) { + this.open = false; + } + } + _computeNotifications(open, hass, notificationsBackend) { if (!open) { return [];