material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[TextField] Disable autofill/autocomplete

Open kkotwal94 opened this issue 10 years ago • 30 comments

something like autocomplete = off on for html would be just as cool/useful for 's I think. Unless you can already do it, but I don't see it in the docs.

Autocomplete by chrome can make it look kind of bad sometimes with certain styling.

kkotwal94 avatar Dec 25 '15 00:12 kkotwal94

In jsx autocomplete = autoComplete

<AutoComplete
    dataSource={cities}
    ...
    autoComplete='off'
/>

w01fgang avatar Jan 16 '16 15:01 w01fgang

derp thank you

kkotwal94 avatar Jan 24 '16 20:01 kkotwal94

Notice that you do no longer need to provide the autoComplete='off' for the AutoComplete component on the master branch. It's added by default.

oliviertassinari avatar Feb 26 '16 21:02 oliviertassinari

This is not working for a normal TextField because you can't pass in custom attributes autoComplete='off' just does nothing.

How can I set autocomplete=off on the input-element?

chapati23 avatar May 17 '16 17:05 chapati23

@chapati23 in the latest version works well

<TextField
  autoComplete='off'
  floatingLabelText="From"
 ...
/>

renders to: screen

You can see in the source code

w01fgang avatar May 17 '16 21:05 w01fgang

apologies, you are correct. must have been either a typo or caching issue on my side, just tried again and it works fine.

chapati23 avatar May 18 '16 14:05 chapati23

@chapati23 that's ok 😃

w01fgang avatar May 18 '16 15:05 w01fgang

I still have issue with that, when I provide the autoComplete ='new-password ' to TextField, react renders it to input, but they still propose to autofill password that I saved.

palaniichukdmytro avatar Jan 18 '18 09:01 palaniichukdmytro

@palaniichukdmytro Confirmed

indapublic avatar May 01 '18 01:05 indapublic

Just an FYI, Google Chrome seemed to not care if I set autoComplete="off" or not, it would always provide an autocomplete... If I set it to autoComplete="no", it worked.

Michael-M-Judd avatar Oct 03 '18 12:10 Michael-M-Judd

I'm using Downshift with Material UI, as per the official Material UI documentation, however I cannot for the life of me get autoComplete to change to a custom value. It always defaults back to 'autocomplete = off' when rendered.

It seems to be a Material UI issue, not Dropshift, as Dropshift sets autoComplete to 'nope' by default since version 2.0.12 - https://github.com/paypal/downshift/releases/tag/v2.0.12

Does anyone know how to fix this issue?

jakec-dev avatar Jan 12 '19 08:01 jakec-dev

Nevermind, I checked the Dropshift source code and it hardcodes autoComplete to 'off'. I'll bring up the issue with them.

jakec-dev avatar Jan 12 '19 08:01 jakec-dev

Why is the option called autoComplete instead of autocomplete? autocomplete is one word and not auto-complete

nlevchuk avatar Apr 05 '19 07:04 nlevchuk

Ask React.

oliviertassinari avatar Apr 05 '19 08:04 oliviertassinari

Is it the same issue like class and className in React?

nlevchuk avatar Apr 05 '19 08:04 nlevchuk

This seems to have worked for me (we are using material ui with redux form)

      <Textfield
        inputProps={{
          autocomplete: "new-password",
        }}
      />

"new-password" works if the input is type="password "off" works if its a regular text field wrapped in a form

BenAhlander avatar May 20 '19 16:05 BenAhlander

@BenAhlander thanks, it worked for me when I used the inputProps. I think material-UI should properly document this.

AnayoOleru avatar Sep 14 '19 21:09 AnayoOleru

Just to reiterate and be very clear:

When using as a password field:

<Textfield
  type="password"
  inputProps={{
    autoComplete: "new-password",
  }}
/>

When using as a text field:

<Textfield
  type="text"
  inputProps={{
    autoComplete: "off",
  }}
/>

andrewmclagan avatar Jan 25 '21 06:01 andrewmclagan

doesn't work for me... I still have suggestions ....

matteo1976 avatar Mar 19 '21 10:03 matteo1976

We document possible solutions in https://next.material-ui.com/components/autocomplete/#autocomplete-autofill. It's not a simple problem.

oliviertassinari avatar Mar 19 '21 11:03 oliviertassinari