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
4 changed files with 25 additions and 2 deletions

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(