Skip to content

Commit

Permalink
Merge pull request #4838 from vdegenne:textfield-autocomplete
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 564437185
  • Loading branch information
copybara-github committed Sep 11, 2023
2 parents a8ce2ab + 4d9d2cb commit c478b3f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions textfield/internal/text-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ export abstract class TextField extends LitElement {
@property({reflect: true})
type: TextFieldType|UnsupportedTextFieldType = 'text';

/**
* Describes what, if any, type of autocomplete functionality the input
* should provide.
*
* https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
*/
@property({reflect: true}) autocomplete = '';

/**
* Returns the text field's validation error message.
*
Expand Down Expand Up @@ -610,6 +618,9 @@ export abstract class TextField extends LitElement {
const style = {direction: this.textDirection};
const ariaLabel =
(this as ARIAMixinStrict).ariaLabel || this.label || nothing;
// lit-anaylzer `autocomplete` types are too strict
// tslint:disable-next-line:no-any
const autocomplete = this.autocomplete as any;

if (this.type === 'textarea') {
return html`
Expand All @@ -619,6 +630,7 @@ export abstract class TextField extends LitElement {
aria-describedby="description"
aria-invalid=${this.hasError}
aria-label=${ariaLabel}
autocomplete=${autocomplete || nothing}
?disabled=${this.disabled}
maxlength=${this.maxLength > -1 ? this.maxLength : nothing}
minlength=${this.minLength > -1 ? this.minLength : nothing}
Expand Down Expand Up @@ -650,6 +662,7 @@ export abstract class TextField extends LitElement {
aria-describedby="description"
aria-invalid=${this.hasError}
aria-label=${ariaLabel}
autocomplete=${autocomplete || nothing}
?disabled=${this.disabled}
inputmode=${inputMode || nothing}
max=${(this.max || nothing) as unknown as number}
Expand Down

0 comments on commit c478b3f

Please sign in to comment.