mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-09 18:36:35 +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``;
|
||||
}
|
||||
const entry = this._params.entry;
|
||||
const nameInvalid = this._name.trim() === "";
|
||||
const nameInvalid = !this._isNameValid();
|
||||
return html`
|
||||
<ha-paper-dialog
|
||||
with-backdrop
|
||||
@ -71,6 +71,7 @@ class DialogAreaDetail extends LitElement {
|
||||
<paper-input
|
||||
.value=${this._name}
|
||||
@value-changed=${this._nameChanged}
|
||||
@keyup=${this._handleKeyup}
|
||||
.label=${this.hass.localize("ui.panel.config.areas.editor.name")}
|
||||
.errorMessage=${this.hass.localize(
|
||||
"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>) {
|
||||
this._error = undefined;
|
||||
this._name = ev.detail.value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user