mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-26 02:36:37 +00:00
Do not close edit dialog when more info is escaped (#10249)
This commit is contained in:
parent
3adbc4cfaf
commit
b5c717a559
@ -75,6 +75,8 @@ 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,6 +95,9 @@ 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;
|
||||||
@ -125,6 +130,16 @@ 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(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
if (!this._params) {
|
if (!this._params) {
|
||||||
return html``;
|
return html``;
|
||||||
@ -157,6 +172,7 @@ export class HuiDialogEditCard
|
|||||||
<ha-dialog
|
<ha-dialog
|
||||||
open
|
open
|
||||||
scrimClickAction
|
scrimClickAction
|
||||||
|
.escapeKeyAction=${this._isEscapeEnabled ? undefined : ""}
|
||||||
@keydown=${this._ignoreKeydown}
|
@keydown=${this._ignoreKeydown}
|
||||||
@closed=${this._cancel}
|
@closed=${this._cancel}
|
||||||
@opened=${this._opened}
|
@opened=${this._opened}
|
||||||
@ -280,6 +296,8 @@ 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