1
0
mirror of https://github.com/home-assistant/frontend.git synced 2026-04-02 00:27:49 +01:00

Prevent scrim close on lovelace editor dialogs (#29653)

* Prevent scrim close on lovelace editor dialogs

* Prevent other editors
This commit is contained in:
Aidan Timson
2026-02-16 12:47:48 +00:00
committed by GitHub
parent 5c95fa65dd
commit a159a84228
5 changed files with 5 additions and 18 deletions

View File

@@ -82,8 +82,6 @@ export class HuiDialogEditBadge
@state() private _dirty = false; @state() private _dirty = false;
@state() private _isEscapeEnabled = true;
public async showDialog(params: EditBadgeDialogParams): Promise<void> { public async showDialog(params: EditBadgeDialogParams): Promise<void> {
this._params = params; this._params = params;
this._GUImode = true; this._GUImode = true;
@@ -126,9 +124,6 @@ export class HuiDialogEditBadge
private _dialogClosed(): void { private _dialogClosed(): void {
this._open = false; this._open = false;
this._isEscapeEnabled = true;
window.removeEventListener("dialog-closed", this._enableEscapeKeyClose);
window.removeEventListener("hass-more-info", this._disableEscapeKeyClose);
this._params = undefined; this._params = undefined;
this._badgeConfig = undefined; this._badgeConfig = undefined;
this._error = undefined; this._error = undefined;
@@ -155,16 +150,6 @@ export class HuiDialogEditBadge
} }
} }
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) { if (!this._params) {
return nothing; return nothing;
@@ -209,7 +194,7 @@ export class HuiDialogEditBadge
.hass=${this.hass} .hass=${this.hass}
.open=${this._open} .open=${this._open}
.width=${this.large ? "full" : "large"} .width=${this.large ? "full" : "large"}
?prevent-scrim-close=${!this._isEscapeEnabled} prevent-scrim-close
@keydown=${this._ignoreKeydown} @keydown=${this._ignoreKeydown}
@closed=${this._dialogClosed} @closed=${this._dialogClosed}
@opened=${this._opened} @opened=${this._opened}
@@ -334,8 +319,6 @@ export class HuiDialogEditBadge
} }
private _opened() { private _opened() {
window.addEventListener("dialog-closed", this._enableEscapeKeyClose);
window.addEventListener("hass-more-info", this._disableEscapeKeyClose);
this._badgeEditorEl?.focusYamlEditor(); this._badgeEditorEl?.focusYamlEditor();
} }

View File

@@ -169,6 +169,7 @@ export class HuiDialogEditCard
.hass=${this.hass} .hass=${this.hass}
.open=${this._open} .open=${this._open}
.width=${this.large ? "full" : "large"} .width=${this.large ? "full" : "large"}
prevent-scrim-close
@keydown=${this._ignoreKeydown} @keydown=${this._ignoreKeydown}
@closed=${this._dialogClosed} @closed=${this._dialogClosed}
@opened=${this._opened} @opened=${this._opened}

View File

@@ -158,6 +158,7 @@ export class HuiDialogEditSection
<ha-dialog <ha-dialog
.hass=${this.hass} .hass=${this.hass}
.open=${this._open} .open=${this._open}
prevent-scrim-close
@keydown=${this._ignoreKeydown} @keydown=${this._ignoreKeydown}
@closed=${this._dialogClosed} @closed=${this._dialogClosed}
class=${classMap({ class=${classMap({

View File

@@ -212,6 +212,7 @@ export class HuiDialogEditView extends LitElement {
.hass=${this.hass} .hass=${this.hass}
.open=${this._open} .open=${this._open}
width="large" width="large"
prevent-scrim-close
@closed=${this._dialogClosed} @closed=${this._dialogClosed}
class=${classMap({ class=${classMap({
"yaml-mode": this._yamlMode, "yaml-mode": this._yamlMode,

View File

@@ -107,6 +107,7 @@ export class HuiDialogEditViewHeader extends LitElement {
.open=${this._open} .open=${this._open}
header-title=${title} header-title=${title}
width="large" width="large"
prevent-scrim-close
@closed=${this._dialogClosed} @closed=${this._dialogClosed}
class=${classMap({ class=${classMap({
"yaml-mode": this._yamlMode, "yaml-mode": this._yamlMode,