close card editor on ESC (#4570)

This commit is contained in:
Ian Richardson 2020-01-23 07:43:09 -06:00 committed by Bram Kragten
parent fc4e3e90b2
commit 9aedeab4fa

View File

@ -86,7 +86,7 @@ export class HuiDialogEditCard extends LitElement {
}
return html`
<ha-paper-dialog with-backdrop opened modal>
<ha-paper-dialog with-backdrop opened modal @keyup=${this._handleKeyUp}>
<h2>
${heading}
</h2>
@ -264,6 +264,12 @@ export class HuiDialogEditCard extends LitElement {
this._error = ev.detail.error;
}
private _handleKeyUp(ev: KeyboardEvent) {
if (ev.keyCode === 27) {
this._close();
}
}
private _close(): void {
this._params = undefined;
this._cardConfig = undefined;