-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[Autocomplete] Better handle native browsers' autofill and autocomplete #18376
[Autocomplete] Better handle native browsers' autofill and autocomplete #18376
Conversation
Details of bundle changes.Comparing: 64ae0c6...c991e8f
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
disabled
was used to disable the autocomplete and autofill feature of the browser. off
wouldn't disable the autofill feature. This is not really documented, related to https://stackoverflow.com/questions/15738259/disabling-chrome-autofill.
I'm curious about this part. Do you have an example? For context, I could test it on Chrome macOS. |
Gotcha, good to know about "disabled" with autofill. I'll send over steps to reproduce shortly. |
I'm experiencing the same Here is a condesandbox. It's the same as the first of the documentation (https://material-ui.com/components/autocomplete/#ComboBox.tsx) , but I added the attribute https://codesandbox.io/s/material-demo-386c6 The problem is that edit: I'm using Chrome Version 78.0.3904.97 (Official Build) (64-bit) in Windows 10 |
The issue shows up for me in development with Storybook, and my Autocomplete component is as follows (similar to the docs). The browser suggestion goes away when I change the id to anything other than "test" or destructure the params being passed to renderInput and override the inputProps.autoComplete
|
@IanSmith89 Thank you, with your solution of |
565af60
to
9a3545a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the codesandbox reproduction. The change seems to help.
However, if I remove the override for the country demo, and after these changes, my browser suggest autofill values, based on the saved addressed of my Google account.
9a3545a
to
c991e8f
Compare
// (autocomplete and autofill) | ||
autoComplete: 'disabled', | ||
// Handle autocomplete but not autofill. | ||
autoComplete: 'off', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also fixes HTML5 validation errors: https://validator.w3.org/nu/?doc=https%3A%2F%2Fdeploy-preview-18376--material-ui.netlify.com%2Fcomponents%2Fautocomplete%2F
@IanSmith89 Thank you |
@IanSmith89, I was super happy to find this, because I was experiencing this very issue and it was driving me CRAZY. However when copying your code, I get an error related to inputProps.autoComplete: Property 'autoComplete' does not exist on type 'object'.ts(2339) https://www.dropbox.com/s/ushry27nim6cr9f/Screenshot%202019-11-21%2013.35.58.png?dl=0 Could you point me in the right direction? This StackOverflow post describes my problem: |
@joshuascott You have to cast it to any. Try this |
Not 100% sure if this is relevant here, but I tried a lot of stuff to turn off autocomplete for TextFields, and in the end what worked for me was wrapping it in a form element like this: <form className={classes.root} noValidate autoComplete="off">
<TextField ... />
</form> |
I'm confused-- if we know Chrome ignores |
I checked the open issues and didn't see anyone else report what I was seeing (the browser autocomplete suggestion was overlaying the Autocomplete options popup). I updated autoComplete to the correct attribute value of "off" in getInputProps that was originally assigned "disabled."
Not sure if a one-liner makes sense for a PR but figured I'd share. Thanks for all the great work on Material UI. I'm a big fan and daily user.