accessible-autocomplete icon indicating copy to clipboard operation
accessible-autocomplete copied to clipboard

Google Chrome forces autofill on fields set autocomplete="off"

Open NickColley opened this issue 6 years ago • 12 comments

We are struggling to disable chrome's autocomplete when using this. We can set autocomplete: "new-password" on the input, but not on the new input in the autocomplete__wrapper. You can see chromes autofill interfering and the relevant autocomplete label in this screencast.

From researching it this morning it seems to be that Chrome is ignoring autocomplete "off" and instead you need to use "new-password".

Chrome intentionally ignores autocomplete="off" and autocomplete="false". However, they put new-password in as a special clause to stop new password forms from being auto-filled.

from https://stackoverflow.com/questions/10938891/disable-form-autofill-in-chrome-without-disabling-autocomplete

screen shot 2019-02-05 at 12 16 21

NickColley avatar Feb 05 '19 12:02 NickColley

This Chromium bug seems relevant: https://bugs.chromium.org/p/chromium/issues/detail?id=468153#c164

NickColley avatar Feb 05 '19 12:02 NickColley

Stolen from @igloosi's Twitter

chrome-autocomplete

dashouse avatar Feb 06 '19 12:02 dashouse

I have added our case to the bug thread: https://bugs.chromium.org/p/chromium/issues/detail?id=914451#c53

NickColley avatar Jul 12 '19 13:07 NickColley

@nickcolley I've been struggling with this bug in Chrome for a long time. The chrome team do not seem to be paying attension to the bug report and seem to actively find new ways to force autocomplete, when you think you've found a work around.

nogginbox avatar Jul 12 '19 16:07 nogginbox

Here's a workaround to fix this problem renderInput={(params) => { const inputProps = params.inputProps inputProps.autoComplete = 'chrome-off' return ( <TextField {...params} inputProps={inputProps} label="Country" size="small" variant="outlined" /> ) }}

zaidsheriff786 avatar Oct 22 '20 11:10 zaidsheriff786

any progress with workaround?

alexey-sh avatar Oct 27 '20 11:10 alexey-sh

I've heard reports that setting the "autocomplete" attribute to a value that's not recognised may help, which could explain why using "chrome-off" might work. Something for the GDS team to investigate if they have time.

NickColley avatar Feb 07 '21 11:02 NickColley

A workaround might be not to name the input something which chrome is looking for to guess what the input is for. Not suggesting to do this everywhere, but if you had one important example like your gif, it might be a way around it.

Regexes look to be here: https://source.chromium.org/chromium/chromium/src/+/master:components/autofill/core/browser/autofill_regex_constants.cc;l=9?q=autofill_regex&ss=chromium%2Fchromium%2Fsrc

Spencerooni avatar Mar 02 '21 09:03 Spencerooni

We have a temporary solution using client side js - rename the name attribute on the client to something random, then restore it on submit. Seems to work so far.

edwardhorsford avatar Mar 02 '21 10:03 edwardhorsford

We're not sure if this is something we can fix as Chrome seem fairly adamant on keeping this behaviour. However, we should do an investigation to see if there's anything we can do as it's easy to see how this can cause issues for users. If we're unable to fix this, we could consider adding something to the guidance about this.

vanitabarrett avatar Jan 11 '22 14:01 vanitabarrett

@vanitabarrett this is absolutely fixable with js - my team (as above) has a working solution. It does introduce a non standard attribute, but I think the benefits greatly outway the downside.

I'm currently working on a PR on my service to clean up the code.

edwardhorsford avatar Jan 11 '22 17:01 edwardhorsford

We also ran into this issue on our project. Setting autocomplete=”chrome-off” was the most promising for us. However, there is a limitation in that it will work for a maximum of 5 input fields; any more than that and Chrome will ignore it for the subsequent input fields.

We had a brief Slack thread on this yesterday and this was probably the best article - both in summarising the limitations of several workarounds and proposing their own JS fix. They are removing the autcomplete attribute onBlur and setting the attribute onFocus.

dlzhry2nhs avatar Jan 12 '22 09:01 dlzhry2nhs