Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

material-ui TextField disable Browser autoComplete

I use material ui v0.20.0 and I have to prohibit saving the password for a user with TextField. I added props to TextField autocomplete='nope' cause not all the browsers understand autocomplete='off'. It seems that the last version of Chrome 63 does not accept it. Sometimes it does not work and sometimes it does. I can not get why it works so hectic. When chrome asks to save password and I save it, and after that I want to edit input I still have this : enter image description here

  <TextField          name='userName'          floatingLabelText={<FormattedMessage id='users.username' />}          value={name || ''}          onChange={(e, name) => this.changeUser({name})}          // autoComplete='new-password'      />       <TextField         name='password'         floatingLabelText={<FormattedMessage id='users.passwords.new' />}         type='password'         value={password || ''}         onChange={(e, password) => this.changeUser({password})}         autoComplete='new-password'    /> 

Looks like it works in Firefox(v57.0.4)

By default TextField does not have autoComplete='off' enter image description here

like image 958
Palaniichuk Dmytro Avatar asked Jan 17 '18 15:01

Palaniichuk Dmytro


People also ask

How do I disable input field autocomplete?

Add autocomplete="off" onto <form> element; Add hidden <input> with autocomplete="false" as a first children element of the form.

How do I turn off autocomplete in React?

To turn off autocomplete on an input field in React, set the autoComplete prop to off or new-password , e.g. <input autoComplete="off" /> . When autoComplete is set to off , the browser is not permitted to automatically enter a value for the field.

What is autocomplete MUI?

The autocomplete is a normal text input enhanced by a panel of suggested options.


Video Answer


1 Answers

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

 <Textfield   inputProps={{     autocomplete: 'new-password',     form: {       autocomplete: 'off',     },   }}   /> 

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

like image 104
Ben Ahlander Avatar answered Oct 09 '22 19:10

Ben Ahlander