Fix autocorrect and spellcheck for ha-textfield (#17274)

This commit is contained in:
Paul Bottein 2023-07-13 16:33:12 +02:00 committed by GitHub
parent 158a816f7a
commit e2ec3b63ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 2 deletions

View File

@ -173,7 +173,7 @@ export class HaComboBox extends LitElement {
autocapitalize="none"
autocomplete="off"
autocorrect="off"
spellcheck="false"
input-spellcheck="false"
.suffix=${html`<div
style="width: 28px;"
role="none presentation"

View File

@ -17,6 +17,11 @@ export class HaTextField extends TextFieldBase {
@property() public autocomplete?: string;
@property() public autocorrect?: string;
@property({ attribute: "input-spellcheck" })
public inputSpellcheck?: string;
@query("input") public formElement!: HTMLInputElement;
override updated(changedProperties: PropertyValues) {
@ -38,6 +43,20 @@ export class HaTextField extends TextFieldBase {
this.formElement.removeAttribute("autocomplete");
}
}
if (changedProperties.has("autocorrect")) {
if (this.autocorrect) {
this.formElement.setAttribute("autocorrect", this.autocorrect);
} else {
this.formElement.removeAttribute("autocorrect");
}
}
if (changedProperties.has("inputSpellcheck")) {
if (this.inputSpellcheck) {
this.formElement.setAttribute("spellcheck", this.inputSpellcheck);
} else {
this.formElement.removeAttribute("spellcheck");
}
}
}
protected override renderIcon(

View File

@ -687,6 +687,10 @@ export class EntityRegistrySettingsEditor extends LitElement {
required
@input=${this._entityIdChanged}
iconTrailing
autocapitalize="none"
autocomplete="off"
autocorrect="off"
input-spellcheck="false"
>
<ha-icon-button
@click=${this._copyEntityId}

View File

@ -202,7 +202,7 @@ class HaPanelDevState extends EventsMixin(LocalizeMixin(PolymerElement)) {
autocapitalize="none"
autocomplete="off"
autocorrect="off"
spellcheck="false"
input-spellcheck="false"
value="[[_state]]"
on-change="stateChanged"
class="state-input"