mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-10 19:06:36 +00:00
Allow pressing return to submit on area dialog (#7509)
This commit is contained in:
parent
d814aa36a7
commit
40b2387667
@ -42,7 +42,7 @@ class DialogAreaDetail extends LitElement {
|
|||||||
return html``;
|
return html``;
|
||||||
}
|
}
|
||||||
const entry = this._params.entry;
|
const entry = this._params.entry;
|
||||||
const nameInvalid = this._name.trim() === "";
|
const nameInvalid = !this._isNameValid();
|
||||||
return html`
|
return html`
|
||||||
<ha-paper-dialog
|
<ha-paper-dialog
|
||||||
with-backdrop
|
with-backdrop
|
||||||
@ -71,6 +71,7 @@ class DialogAreaDetail extends LitElement {
|
|||||||
<paper-input
|
<paper-input
|
||||||
.value=${this._name}
|
.value=${this._name}
|
||||||
@value-changed=${this._nameChanged}
|
@value-changed=${this._nameChanged}
|
||||||
|
@keyup=${this._handleKeyup}
|
||||||
.label=${this.hass.localize("ui.panel.config.areas.editor.name")}
|
.label=${this.hass.localize("ui.panel.config.areas.editor.name")}
|
||||||
.errorMessage=${this.hass.localize(
|
.errorMessage=${this.hass.localize(
|
||||||
"ui.panel.config.areas.editor.name_required"
|
"ui.panel.config.areas.editor.name_required"
|
||||||
@ -104,6 +105,16 @@ class DialogAreaDetail extends LitElement {
|
|||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _isNameValid() {
|
||||||
|
return this._name.trim() !== "";
|
||||||
|
}
|
||||||
|
|
||||||
|
private _handleKeyup(ev: KeyboardEvent) {
|
||||||
|
if (ev.keyCode === 13 && this._isNameValid() && !this._submitting) {
|
||||||
|
this._updateEntry();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private _nameChanged(ev: PolymerChangedEvent<string>) {
|
private _nameChanged(ev: PolymerChangedEvent<string>) {
|
||||||
this._error = undefined;
|
this._error = undefined;
|
||||||
this._name = ev.detail.value;
|
this._name = ev.detail.value;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user