Form fields should not init in the error state (#17615)

This commit is contained in:
Simon Lamon 2023-08-21 15:49:27 +02:00 committed by GitHub
parent e764076b1a
commit bfcdbbd70b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 17 deletions

View File

@ -176,7 +176,7 @@ class DialogCalendarEventEditor extends LitElement {
.value=${this._summary} .value=${this._summary}
required required
@change=${this._handleSummaryChanged} @change=${this._handleSummaryChanged}
error-message=${this.hass.localize("ui.common.error_required")} .validationMessage=${this.hass.localize("ui.common.error_required")}
dialogInitialFocus dialogInitialFocus
></ha-textfield> ></ha-textfield>
<ha-textarea <ha-textarea

View File

@ -191,7 +191,7 @@ export class DialogAddApplicationCredential extends LitElement {
.value=${this._name} .value=${this._name}
required required
@input=${this._handleValueChanged} @input=${this._handleValueChanged}
error-message=${this.hass.localize("ui.common.error_required")} .validationMessage=${this.hass.localize("ui.common.error_required")}
dialogInitialFocus dialogInitialFocus
></ha-textfield> ></ha-textfield>
<ha-textfield <ha-textfield
@ -203,7 +203,7 @@ export class DialogAddApplicationCredential extends LitElement {
.value=${this._clientId} .value=${this._clientId}
required required
@input=${this._handleValueChanged} @input=${this._handleValueChanged}
error-message=${this.hass.localize("ui.common.error_required")} .validationMessage=${this.hass.localize("ui.common.error_required")}
dialogInitialFocus dialogInitialFocus
.helper=${this.hass.localize( .helper=${this.hass.localize(
"ui.panel.config.application_credentials.editor.client_id_helper" "ui.panel.config.application_credentials.editor.client_id_helper"
@ -219,7 +219,7 @@ export class DialogAddApplicationCredential extends LitElement {
.value=${this._clientSecret} .value=${this._clientSecret}
required required
@input=${this._handleValueChanged} @input=${this._handleValueChanged}
error-message=${this.hass.localize("ui.common.error_required")} .validationMessage=${this.hass.localize("ui.common.error_required")}
.helper=${this.hass.localize( .helper=${this.hass.localize(
"ui.panel.config.application_credentials.editor.client_secret_helper" "ui.panel.config.application_credentials.editor.client_secret_helper"
)} )}

View File

@ -93,10 +93,10 @@ class DialogAreaDetail extends LitElement {
.value=${this._name} .value=${this._name}
@input=${this._nameChanged} @input=${this._nameChanged}
.label=${this.hass.localize("ui.panel.config.areas.editor.name")} .label=${this.hass.localize("ui.panel.config.areas.editor.name")}
.errorMessage=${this.hass.localize( .validationMessage=${this.hass.localize(
"ui.panel.config.areas.editor.name_required" "ui.panel.config.areas.editor.name_required"
)} )}
.invalid=${nameInvalid} required
dialogInitialFocus dialogInitialFocus
></ha-textfield> ></ha-textfield>

View File

@ -516,7 +516,7 @@ export class EntityRegistrySettingsEditor extends LitElement {
${domain === "lock" ${domain === "lock"
? html` ? html`
<ha-textfield <ha-textfield
.errorMessage=${this.hass.localize( .validationMessage=${this.hass.localize(
"ui.dialogs.entity_registry.editor.default_code_error" "ui.dialogs.entity_registry.editor.default_code_error"
)} )}
.value=${this._defaultCode == null ? "" : this._defaultCode} .value=${this._defaultCode == null ? "" : this._defaultCode}

View File

@ -121,11 +121,10 @@ class DialogPersonDetail extends LitElement {
.value=${this._name} .value=${this._name}
@input=${this._nameChanged} @input=${this._nameChanged}
label=${this.hass!.localize("ui.panel.config.person.detail.name")} label=${this.hass!.localize("ui.panel.config.person.detail.name")}
error-message=${this.hass!.localize( .validationMessage=${this.hass!.localize(
"ui.panel.config.person.detail.name_error_msg" "ui.panel.config.person.detail.name_error_msg"
)} )}
required required
auto-validate
></ha-textfield> ></ha-textfield>
<ha-picture-upload <ha-picture-upload
.hass=${this.hass} .hass=${this.hass}

View File

@ -95,11 +95,10 @@ class DialogTagDetail
.configValue=${"name"} .configValue=${"name"}
@input=${this._valueChanged} @input=${this._valueChanged}
.label=${this.hass!.localize("ui.panel.config.tag.detail.name")} .label=${this.hass!.localize("ui.panel.config.tag.detail.name")}
.errorMessage=${this.hass!.localize( .validationMessage=${this.hass!.localize(
"ui.panel.config.tag.detail.required_error_msg" "ui.panel.config.tag.detail.required_error_msg"
)} )}
required required
auto-validate
></ha-textfield> ></ha-textfield>
${!this._params.entry ${!this._params.entry
? html`<ha-textfield ? html`<ha-textfield
@ -154,7 +153,7 @@ class DialogTagDetail
<mwc-button <mwc-button
slot="primaryAction" slot="primaryAction"
@click=${this._updateEntry} @click=${this._updateEntry}
.disabled=${this._submitting} .disabled=${this._submitting || !this._name}
> >
${this._params.entry ${this._params.entry
? this.hass!.localize("ui.panel.config.tag.detail.update") ? this.hass!.localize("ui.panel.config.tag.detail.update")
@ -164,7 +163,7 @@ class DialogTagDetail
? html` <mwc-button ? html` <mwc-button
slot="primaryAction" slot="primaryAction"
@click=${this._updateWriteEntry} @click=${this._updateWriteEntry}
.disabled=${this._submitting} .disabled=${this._submitting || !this._name}
> >
${this.hass!.localize( ${this.hass!.localize(
"ui.panel.config.tag.detail.create_and_write" "ui.panel.config.tag.detail.create_and_write"
@ -271,6 +270,10 @@ class DialogTagDetail
#qr { #qr {
text-align: center; text-align: center;
} }
ha-textfield {
display: block;
margin: 8px 0;
}
`, `,
]; ];
} }

View File

@ -107,7 +107,9 @@ export class DialogAddUser extends LitElement {
)} )}
.value=${this._name} .value=${this._name}
required required
.errorMessage=${this.hass.localize("ui.common.error_required")} .validationMessage=${this.hass.localize(
"ui.common.error_required"
)}
@input=${this._handleValueChanged} @input=${this._handleValueChanged}
@blur=${this._maybePopulateUsername} @blur=${this._maybePopulateUsername}
dialogInitialFocus dialogInitialFocus
@ -122,7 +124,7 @@ export class DialogAddUser extends LitElement {
.value=${this._username} .value=${this._username}
required required
@input=${this._handleValueChanged} @input=${this._handleValueChanged}
.errorMessage=${this.hass.localize("ui.common.error_required")} .validationMessage=${this.hass.localize("ui.common.error_required")}
dialogInitialFocus dialogInitialFocus
></ha-textfield> ></ha-textfield>
@ -135,7 +137,7 @@ export class DialogAddUser extends LitElement {
.value=${this._password} .value=${this._password}
required required
@input=${this._handleValueChanged} @input=${this._handleValueChanged}
.errorMessage=${this.hass.localize("ui.common.error_required")} .validationMessage=${this.hass.localize("ui.common.error_required")}
></ha-textfield> ></ha-textfield>
<ha-textfield <ha-textfield
@ -150,7 +152,7 @@ export class DialogAddUser extends LitElement {
.invalid=${this._password !== "" && .invalid=${this._password !== "" &&
this._passwordConfirm !== "" && this._passwordConfirm !== "" &&
this._passwordConfirm !== this._password} this._passwordConfirm !== this._password}
.errorMessage=${this.hass.localize( .validationMessage=${this.hass.localize(
"ui.panel.config.users.add_user.password_not_match" "ui.panel.config.users.add_user.password_not_match"
)} )}
></ha-textfield> ></ha-textfield>