question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Why is there interference between mat-autocomplete and browser autocomplete?

See original GitHub issue

Bug:

Clicking on autocomplete opens browser autocomplete on top of material2 autocomplete Note: sometimes it takes a double click to re open the browser’s autocomplete.

Expected behavior:

Browser autocomplete should be disabled

Current implementation

<mat-form-field id="recipe-form__nations" >
    <input type="text" matInput ngModel name="nation" placeholder="Nation" autocomplete="off" [matAutocomplete]="auto">
    <mat-autocomplete  #auto="matAutocomplete">
        <mat-option *ngFor="let nation of nationalities" [value]="">
            {{ nation }}
        </mat-option>
    </mat-autocomplete>
</mat-form-field>

Version in use?


    "@angular/animations": "6.0.5",
    "@angular/cdk": "^6.2.1",
    "@angular/common": "6.0.5",
    "@angular/compiler": "6.0.5",
    "@angular/core": "6.0.5",
    "@angular/forms": "6.0.5",
    "@angular/http": "6.0.5",
    "@angular/material": "^6.2.1",

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
crisbetocommented, Jun 18, 2018

Material does set autocomplete="off", but it seems like browsers can ignore it in some cases (see https://stackoverflow.com/questions/12374442/chrome-browser-ignoring-autocomplete-off). I could work around it by setting it to a random value instead of off (e.g. autocomplete="something"), but I’m not sure what the accessibility implications might be if we rolled this into Material.

1reaction
thw0rtedcommented, Feb 14, 2019

I came here to complain that it’s still broken, but it turns out that you need a non-standard autocomplete attribute and a name attribute, or you wind up with browser autofill.

I don’t suppose a Googler on the Material team could talk to a Googler on the Chrome team about making this Just Work without us devs having to override the autocomplete attribute all the time? To be clear, with the way Chrome respects autocomplete=off (i.e., it doesn’t, at all), it never makes sense to allow autocomplete=off in a matAutocompleteTrigger; it should be a compile-time error, or ideally, Material should just magically fix it for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

angular - Why is Material 2 Autocomplete interfered by Browser ...
When the migration is complete, you will access your Teams at stackoverflowteams.com, and they will no longer appear in the left sidebar on...
Read more >
Tk Angular Autocomplete - StackBlitz
import {MatNativeDateModule} from '@angular/. material';. import {BrowserModule} from '@angular/. platform-browser';. import {platformBrowserDynamic} from.
Read more >
can't bind to 'matautocomplete' since it isn't a known property ...
If 'mat-autocomplete' is a Web Component then add 'CUSTOMELEMENTSSCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("nput ...
Read more >
Autocomplete with Angular InstantSearch - Algolia
indices : the list of suggestions,; refine : a function that takes a query string and retrieves relevant suggestions. TypeScript.
Read more >
Reusable Angular Material Input Autocomplete form control
The input's placeholder and the number of characters to trigger the ... Inner form control to link input text changes to mat autocomplete ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found