mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 17:56:46 +00:00
Fix enter behavior of card editor (#6179)
This commit is contained in:
parent
61fdab294a
commit
9ffd25e3a0
@ -158,6 +158,7 @@ export class HuiCardEditor extends LitElement {
|
|||||||
.error=${this._error}
|
.error=${this._error}
|
||||||
.rtl=${computeRTL(this.hass)}
|
.rtl=${computeRTL(this.hass)}
|
||||||
@value-changed=${this._handleYAMLChanged}
|
@value-changed=${this._handleYAMLChanged}
|
||||||
|
@keydown=${this._ignoreKeydown}
|
||||||
></ha-code-editor>
|
></ha-code-editor>
|
||||||
</div>
|
</div>
|
||||||
`}
|
`}
|
||||||
@ -280,6 +281,10 @@ export class HuiCardEditor extends LitElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _ignoreKeydown(ev: KeyboardEvent) {
|
||||||
|
ev.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResult {
|
static get styles(): CSSResult {
|
||||||
return css`
|
return css`
|
||||||
:host {
|
:host {
|
||||||
|
@ -119,8 +119,8 @@ export class HuiDialogEditCard extends LitElement {
|
|||||||
<ha-dialog
|
<ha-dialog
|
||||||
open
|
open
|
||||||
scrimClickAction
|
scrimClickAction
|
||||||
escapeKeyAction
|
@keydown=${this._ignoreKeydown}
|
||||||
@keyup=${this._handleKeyUp}
|
@closed=${this._close}
|
||||||
.heading=${html`${heading}
|
.heading=${html`${heading}
|
||||||
${this._documentationURL !== undefined
|
${this._documentationURL !== undefined
|
||||||
? html`
|
? html`
|
||||||
@ -156,6 +156,7 @@ export class HuiDialogEditCard extends LitElement {
|
|||||||
.value=${this._cardConfig}
|
.value=${this._cardConfig}
|
||||||
@config-changed=${this._handleConfigChanged}
|
@config-changed=${this._handleConfigChanged}
|
||||||
@GUImode-changed=${this._handleGUIModeChanged}
|
@GUImode-changed=${this._handleGUIModeChanged}
|
||||||
|
@editor-save=${this._save}
|
||||||
></hui-card-editor>
|
></hui-card-editor>
|
||||||
</div>
|
</div>
|
||||||
<div class="element-preview">
|
<div class="element-preview">
|
||||||
@ -192,26 +193,33 @@ export class HuiDialogEditCard extends LitElement {
|
|||||||
</mwc-button>
|
</mwc-button>
|
||||||
`
|
`
|
||||||
: ""}
|
: ""}
|
||||||
<mwc-button slot="primaryAction" @click=${this._close}>
|
<div slot="primaryAction" @click=${this._save}>
|
||||||
${this.hass!.localize("ui.common.cancel")}
|
<mwc-button @click=${this._close}>
|
||||||
</mwc-button>
|
${this.hass!.localize("ui.common.cancel")}
|
||||||
${this._cardConfig !== undefined
|
</mwc-button>
|
||||||
? html`
|
${this._cardConfig !== undefined
|
||||||
<mwc-button
|
? html`
|
||||||
slot="primaryAction"
|
<mwc-button
|
||||||
?disabled=${!this._canSave || this._saving}
|
?disabled=${!this._canSave || this._saving}
|
||||||
@click=${this._save}
|
@click=${this._save}
|
||||||
>
|
>
|
||||||
${this._saving
|
${this._saving
|
||||||
? html` <paper-spinner active alt="Saving"></paper-spinner> `
|
? html`
|
||||||
: this.hass!.localize("ui.common.save")}
|
<paper-spinner active alt="Saving"></paper-spinner>
|
||||||
</mwc-button>
|
`
|
||||||
`
|
: this.hass!.localize("ui.common.save")}
|
||||||
: ``}
|
</mwc-button>
|
||||||
|
`
|
||||||
|
: ``}
|
||||||
|
</div>
|
||||||
</ha-dialog>
|
</ha-dialog>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _ignoreKeydown(ev: KeyboardEvent) {
|
||||||
|
ev.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
static get styles(): CSSResultArray {
|
static get styles(): CSSResultArray {
|
||||||
return [
|
return [
|
||||||
haStyleDialog,
|
haStyleDialog,
|
||||||
@ -339,12 +347,6 @@ export class HuiDialogEditCard extends LitElement {
|
|||||||
this._guiModeAvailable = ev.detail.guiModeAvailable;
|
this._guiModeAvailable = ev.detail.guiModeAvailable;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _handleKeyUp(ev: KeyboardEvent) {
|
|
||||||
if (ev.keyCode === 27) {
|
|
||||||
this._close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private _handleGUIModeChanged(ev: HASSDomEvent<GUIModeChangedEvent>): void {
|
private _handleGUIModeChanged(ev: HASSDomEvent<GUIModeChangedEvent>): void {
|
||||||
ev.stopPropagation();
|
ev.stopPropagation();
|
||||||
this._GUImode = ev.detail.guiMode;
|
this._GUImode = ev.detail.guiMode;
|
||||||
@ -376,6 +378,9 @@ export class HuiDialogEditCard extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async _save(): Promise<void> {
|
private async _save(): Promise<void> {
|
||||||
|
if (!this._canSave || this._saving) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this._saving = true;
|
this._saving = true;
|
||||||
await this._params!.saveConfig(
|
await this._params!.saveConfig(
|
||||||
this._params!.path.length === 1
|
this._params!.path.length === 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user