Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] Problem with disabling auto-complete on text-field with type "password" #2792

Closed
ObiWanKenobi opened this issue Dec 14, 2017 · 18 comments
Labels
invalid The issue is missing information or is not a valid bug/feature request

Comments

@ObiWanKenobi
Copy link

ObiWanKenobi commented Dec 14, 2017

Versions and Environment

Vuetify: 0.17.3
Vue: 2.5.3
Browsers: Chrome 63.0.3239.84
OS: Mac OS 10.13.1

Steps to reproduce

https://i.snag.gy/TXN1Kd.jpg

I can't disable Google's autocomplete on v-text-field's with "password"-type. I've tried autocomplete="off".

<v-text-field
    name="password"
    label="Password"
    type="password"
    v-model="password"
    :disabled="working"
    :rules="passwordRule"
    required
/>

Expected Behavior

That the component stops googles autocomplete

Actual Behavior

It does not stop the autocomplete

@nekosaur nekosaur added the pending review The issue is still pending disposition label Dec 14, 2017
@manico
Copy link
Contributor

manico commented Dec 16, 2017

That does not sound like autocomplete but Chrome autofill feature.

@KaelWD
Copy link
Member

KaelWD commented Dec 17, 2017

autocomplete="off" doesn't work for login forms

@KaelWD KaelWD closed this as completed Dec 17, 2017
@KaelWD KaelWD added invalid The issue is missing information or is not a valid bug/feature request and removed pending review The issue is still pending disposition labels Dec 17, 2017
@kgrosvenor
Copy link

this is a UI bug, i just raised the same issue - if field has some text in it, we could add the class that adds the label above on the page render, can we re open this issue?

@kgrosvenor
Copy link

And for me this also only happens when go the login page on a fresh window, or i refresh it - if i start on another router view then go to the login screen, it's fine

@amazzoccone
Copy link

Someone with a solution for this bug?

@ElMatella
Copy link

I hate to do that, but because autocomplete="off" does not work I used autocomplete="new-password' on each of my inputs and it works... I hope Chrome will find a better way to handle that because all Vue/React/Angular devs have problems with that and fix it with nasty hacks

@Flamenco
Copy link
Contributor

Flamenco commented Oct 11, 2018

I created a mixin that solves the issue on Chrome. Add it to the component that creates your text fields, selects, combos, autocompletes, etc.

/*
This Vue mixin will prevent Chrome autocomplete on text fields by setting autocomplete='new-password' where autocomplete='off' for every input that exists inside a component.
 
The DOM is checked on every update.

 */

const isChrome = /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);

const mixin = {
  methods: {
    _repairAutocomplete() {
      const el = this.$el
      el.querySelectorAll('input[type="text"][autocomplete="off"').forEach(it => {
        it.setAttribute('autocomplete', 'new-password')
      })
    }
  },
  mounted() {
    this._repairAutocomplete()
  },
  updated() {
    this._repairAutocomplete()
  }
}

export default isChrome ? mixin : {}

@chris104957
Copy link

Sorry for digging up an old thread, but after being unable to find the solution to this, I finally managed to get it working like this:

<v-text-field
  id="password" 
  browser-autocomplete="new-password" <==== this bit
  prepend-icon="lock" 
  name="password" 
  hide-details
  label="Password"
  outline
  type="password" 
  v-model="password"
></v-text-field>

It still behaves a bit weirdly - If I put browser-autocomplete="new-password" on my username field, then it doesn't do anything. However, if I put it on my password field, then it works as expected, but also prevents autocomplete on any other field in the same form

I'm sharing it here in case it helps anyone else, as this is the first page that I landed on when Googling the problem

@baggrek
Copy link

baggrek commented Nov 18, 2019

change label to placeholder, and this fixing in same issue

@clouder
Copy link

clouder commented Apr 7, 2020

I wouldn't say it's a problem, but this behavior still exists today. I found this issue having a Google search. Piggy backing off of @baggrek suggestion (which didn't help in my case), the solution I came up with was to change the name attribute on the v-autocomplete. Google Auto FIll makes assumtions about what the field is, I'm guessing based on that attribute and possbily also the contents of the select. To fix this, just give it a name and stay away from generic names such as 'name', 'firstname', 'address', If you want to use something like 'name' you can prepend it much the same way we do with our vue components anyway. i.e. name='myapp-name'.

Hope this helps other who google search the same thing I did

Sorry for bumping an old closed issue

@henon
Copy link

henon commented Apr 8, 2020

To follow up on chris' post above: I tried browser-autocomplete and got this message

[Vuetify] [BREAKING] 'browser-autocomplete' has been removed, use 'autocomplete' instead. For more information, see the upgrade guide https://github.com/vuetifyjs/vuetify/releases/tag/v2.0.0#user-content-upgrade-guide

changing to autocomplete="new-password" did turn off chrome's autofill for me

@bob-lee
Copy link

bob-lee commented May 8, 2020

@clouder comment help me to defeat autofill.

              <v-text-field
                v-model="editedItem.region"
                :autocomplete="autocomplete"
                name="editedItem.region"

with data autocomplete: new Date().getTime().toString(),

This trick worked on all v-text-field but not on v-combobox which still shows some suggestion.

@neiromendez
Copy link

sadly this not work for me, only when I press the space on android mobile chrome @bob-lee

@kremda
Copy link

kremda commented May 13, 2020

The only workaround that works for me is to set some random name :name="Math.random()"

@ElMatella
Copy link

@kremda same here. Setting name to an uuid/v4 value to be sure that it is unique across time ;)

@jhallinan
Copy link

The only workaround that works for me is to set some random name :name="Math.random()"

This worked for me. Quite ridiculous the effort involved in preventing autofill.

@onegeco
Copy link

onegeco commented Nov 3, 2021

This solved the problem for me by adding autocomplete="new-password"

@u-nel
Copy link

u-nel commented May 24, 2022

autocomplete="null"

Thank me later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid The issue is missing information or is not a valid bug/feature request
Projects
None yet
Development

No branches or pull requests