mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-23 17:26:42 +00:00
Don't close 2 dialogs from 1 escape keydown (more-info) (#23702)
This commit is contained in:
parent
21c2351137
commit
2105793355
@ -97,6 +97,8 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
|
|
||||||
@state() private _infoEditMode = false;
|
@state() private _infoEditMode = false;
|
||||||
|
|
||||||
|
@state() private _isEscapeEnabled = true;
|
||||||
|
|
||||||
@state() private _sensorNumericDeviceClasses?: string[] = [];
|
@state() private _sensorNumericDeviceClasses?: string[] = [];
|
||||||
|
|
||||||
public showDialog(params: MoreInfoDialogParams) {
|
public showDialog(params: MoreInfoDialogParams) {
|
||||||
@ -132,6 +134,9 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
this._childView = undefined;
|
this._childView = undefined;
|
||||||
this._infoEditMode = false;
|
this._infoEditMode = false;
|
||||||
this._initialView = DEFAULT_VIEW;
|
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 });
|
fireEvent(this, "dialog-closed", { dialog: this.localName });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,6 +295,8 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
<ha-dialog
|
<ha-dialog
|
||||||
open
|
open
|
||||||
@closed=${this.closeDialog}
|
@closed=${this.closeDialog}
|
||||||
|
@opened=${this._handleOpened}
|
||||||
|
.escapeKeyAction=${this._isEscapeEnabled ? undefined : ""}
|
||||||
.heading=${title}
|
.heading=${title}
|
||||||
hideActions
|
hideActions
|
||||||
flexContent
|
flexContent
|
||||||
@ -540,6 +547,19 @@ export class MoreInfoDialog extends LitElement {
|
|||||||
this.large = !this.large;
|
this.large = !this.large;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _handleOpened() {
|
||||||
|
window.addEventListener("dialog-closed", this._enableEscapeKeyClose);
|
||||||
|
window.addEventListener("show-dialog", this._disableEscapeKeyClose);
|
||||||
|
}
|
||||||
|
|
||||||
|
private _enableEscapeKeyClose = () => {
|
||||||
|
this._isEscapeEnabled = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
private _disableEscapeKeyClose = () => {
|
||||||
|
this._isEscapeEnabled = false;
|
||||||
|
};
|
||||||
|
|
||||||
static get styles() {
|
static get styles() {
|
||||||
return [
|
return [
|
||||||
haStyleDialog,
|
haStyleDialog,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user