From 2105793355022bce6360c5cf08058ca878bac574 Mon Sep 17 00:00:00 2001 From: karwosts <32912880+karwosts@users.noreply.github.com> Date: Thu, 16 Jan 2025 07:44:50 -0800 Subject: [PATCH] Don't close 2 dialogs from 1 escape keydown (more-info) (#23702) --- src/dialogs/more-info/ha-more-info-dialog.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/dialogs/more-info/ha-more-info-dialog.ts b/src/dialogs/more-info/ha-more-info-dialog.ts index 793cf78cd2..b078a1d6f4 100644 --- a/src/dialogs/more-info/ha-more-info-dialog.ts +++ b/src/dialogs/more-info/ha-more-info-dialog.ts @@ -97,6 +97,8 @@ export class MoreInfoDialog extends LitElement { @state() private _infoEditMode = false; + @state() private _isEscapeEnabled = true; + @state() private _sensorNumericDeviceClasses?: string[] = []; public showDialog(params: MoreInfoDialogParams) { @@ -132,6 +134,9 @@ export class MoreInfoDialog extends LitElement { this._childView = undefined; this._infoEditMode = false; this._initialView = DEFAULT_VIEW; + this._isEscapeEnabled = true; + window.removeEventListener("dialog-closed", this._enableEscapeKeyClose); + window.removeEventListener("show-dialog", this._disableEscapeKeyClose); fireEvent(this, "dialog-closed", { dialog: this.localName }); } @@ -290,6 +295,8 @@ export class MoreInfoDialog extends LitElement { { + this._isEscapeEnabled = true; + }; + + private _disableEscapeKeyClose = () => { + this._isEscapeEnabled = false; + }; + static get styles() { return [ haStyleDialog,