diff --git a/src/panels/lovelace/editor/card-editor/hui-card-editor.ts b/src/panels/lovelace/editor/card-editor/hui-card-editor.ts index 4d884e469c..49a7ad7511 100644 --- a/src/panels/lovelace/editor/card-editor/hui-card-editor.ts +++ b/src/panels/lovelace/editor/card-editor/hui-card-editor.ts @@ -158,6 +158,7 @@ export class HuiCardEditor extends LitElement { .error=${this._error} .rtl=${computeRTL(this.hass)} @value-changed=${this._handleYAMLChanged} + @keydown=${this._ignoreKeydown} > `} @@ -280,6 +281,10 @@ export class HuiCardEditor extends LitElement { } } + private _ignoreKeydown(ev: KeyboardEvent) { + ev.stopPropagation(); + } + static get styles(): CSSResult { return css` :host { diff --git a/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts b/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts index 93ae17ff3f..dae6c63033 100755 --- a/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts +++ b/src/panels/lovelace/editor/card-editor/hui-dialog-edit-card.ts @@ -119,8 +119,8 @@ export class HuiDialogEditCard extends LitElement {
@@ -192,26 +193,33 @@ export class HuiDialogEditCard extends LitElement { ` : ""} - - ${this.hass!.localize("ui.common.cancel")} - - ${this._cardConfig !== undefined - ? html` - - ${this._saving - ? html` ` - : this.hass!.localize("ui.common.save")} - - ` - : ``} +
+ + ${this.hass!.localize("ui.common.cancel")} + + ${this._cardConfig !== undefined + ? html` + + ${this._saving + ? html` + + ` + : this.hass!.localize("ui.common.save")} + + ` + : ``} +
`; } + private _ignoreKeydown(ev: KeyboardEvent) { + ev.stopPropagation(); + } + static get styles(): CSSResultArray { return [ haStyleDialog, @@ -339,12 +347,6 @@ export class HuiDialogEditCard extends LitElement { this._guiModeAvailable = ev.detail.guiModeAvailable; } - private _handleKeyUp(ev: KeyboardEvent) { - if (ev.keyCode === 27) { - this._close(); - } - } - private _handleGUIModeChanged(ev: HASSDomEvent): void { ev.stopPropagation(); this._GUImode = ev.detail.guiMode; @@ -376,6 +378,9 @@ export class HuiDialogEditCard extends LitElement { } private async _save(): Promise { + if (!this._canSave || this._saving) { + return; + } this._saving = true; await this._params!.saveConfig( this._params!.path.length === 1