mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 03:06:41 +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 _isEscapeEnabled = true;
|
||||
|
||||
public async showDialog(params: EditCardDialogParams): Promise<void> {
|
||||
this._params = params;
|
||||
this._GUImode = true;
|
||||
@ -93,9 +91,6 @@ export class HuiDialogEditCard
|
||||
}
|
||||
|
||||
public closeDialog(): boolean {
|
||||
this._isEscapeEnabled = true;
|
||||
window.removeEventListener("dialog-closed", this._enableEscapeKeyClose);
|
||||
window.removeEventListener("hass-more-info", this._disableEscapeKeyClose);
|
||||
if (this._dirty) {
|
||||
this._confirmCancel();
|
||||
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() {
|
||||
if (!this._params || !this._cardConfig) {
|
||||
return nothing;
|
||||
@ -170,7 +155,7 @@ export class HuiDialogEditCard
|
||||
<ha-dialog
|
||||
open
|
||||
scrimClickAction
|
||||
.escapeKeyAction=${this._isEscapeEnabled ? undefined : ""}
|
||||
escapeKeyAction
|
||||
@keydown=${this._ignoreKeydown}
|
||||
@closed=${this._cancel}
|
||||
@opened=${this._opened}
|
||||
@ -304,8 +289,6 @@ export class HuiDialogEditCard
|
||||
}
|
||||
|
||||
private _opened() {
|
||||
window.addEventListener("dialog-closed", this._enableEscapeKeyClose);
|
||||
window.addEventListener("hass-more-info", this._disableEscapeKeyClose);
|
||||
this._cardEditorEl?.focusYamlEditor();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user