mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +00:00
Disable escape key to close edit card dialog (#25947)
This commit is contained in:
parent
018aceb542
commit
a952b880d8
@ -74,8 +74,6 @@ export class HuiDialogEditCard
|
|||||||
|
|
||||||
@state() private _dirty = false;
|
@state() private _dirty = false;
|
||||||
|
|
||||||
@state() private _isEscapeEnabled = true;
|
|
||||||
|
|
||||||
public async showDialog(params: EditCardDialogParams): Promise<void> {
|
public async showDialog(params: EditCardDialogParams): Promise<void> {
|
||||||
this._params = params;
|
this._params = params;
|
||||||
this._GUImode = true;
|
this._GUImode = true;
|
||||||
@ -93,9 +91,6 @@ export class HuiDialogEditCard
|
|||||||
}
|
}
|
||||||
|
|
||||||
public closeDialog(): boolean {
|
public closeDialog(): boolean {
|
||||||
this._isEscapeEnabled = true;
|
|
||||||
window.removeEventListener("dialog-closed", this._enableEscapeKeyClose);
|
|
||||||
window.removeEventListener("hass-more-info", this._disableEscapeKeyClose);
|
|
||||||
if (this._dirty) {
|
if (this._dirty) {
|
||||||
this._confirmCancel();
|
this._confirmCancel();
|
||||||
return false;
|
return false;
|
||||||
@ -124,16 +119,6 @@ export class HuiDialogEditCard
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private _enableEscapeKeyClose = (ev: any) => {
|
|
||||||
if (ev.detail.dialog === "ha-more-info-dialog") {
|
|
||||||
this._isEscapeEnabled = true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private _disableEscapeKeyClose = () => {
|
|
||||||
this._isEscapeEnabled = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
protected render() {
|
protected render() {
|
||||||
if (!this._params || !this._cardConfig) {
|
if (!this._params || !this._cardConfig) {
|
||||||
return nothing;
|
return nothing;
|
||||||
@ -170,7 +155,7 @@ export class HuiDialogEditCard
|
|||||||
<ha-dialog
|
<ha-dialog
|
||||||
open
|
open
|
||||||
scrimClickAction
|
scrimClickAction
|
||||||
.escapeKeyAction=${this._isEscapeEnabled ? undefined : ""}
|
escapeKeyAction
|
||||||
@keydown=${this._ignoreKeydown}
|
@keydown=${this._ignoreKeydown}
|
||||||
@closed=${this._cancel}
|
@closed=${this._cancel}
|
||||||
@opened=${this._opened}
|
@opened=${this._opened}
|
||||||
@ -304,8 +289,6 @@ export class HuiDialogEditCard
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _opened() {
|
private _opened() {
|
||||||
window.addEventListener("dialog-closed", this._enableEscapeKeyClose);
|
|
||||||
window.addEventListener("hass-more-info", this._disableEscapeKeyClose);
|
|
||||||
this._cardEditorEl?.focusYamlEditor();
|
this._cardEditorEl?.focusYamlEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user