-
-
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] Requires two clicks to open on mobile ios after state is set #21049
Comments
Can reproduce. Here's the codesandbox link: https://codesandbox.io/s/romantic-meninsky-kcqgh |
I can't explain the behavior. No idea. |
Wow... after some digging (and some blind luck) I found the issue. Looks like the dreaded "double-tap link" issue has resurfaced: https://css-tricks.com/annoying-mobile-double-tap-link-issue/. Summary: iOS is great and if a ":hover" rule is detected you need to double tap to click. |
@joshwooding Thanks for looking into this so quickly. I'm considering using this component in a project within the next couple weeks. Do you think there will be a quick fix / workaround or should I look into an alternative? Thanks |
@joshwooding Awesome. @kaplantm What do you think of this fix? Do you want to work on a pull request? :) diff --git a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
index ddb4f1d71..da2e010cf 100644
--- a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
+++ b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
@@ -16,9 +16,14 @@ export { createFilterOptions };
export const styles = (theme) => ({
/* Styles applied to the root element. */
root: {
- '&:hover $clearIndicatorDirty, &$focused $clearIndicatorDirty': {
+ '&$focused $clearIndicatorDirty': {
visibility: 'visible',
},
+ // Avoid double tap issue on iOS
+ '@media (pointer: fine)': {
+ '&:hover $clearIndicatorDirty': {
+ visibility: 'visible',
+ },
+ },
},
/* Styles applied to the root element if `fullWidth={true}`. */
fullWidth: { We already use the fine media query for the date picker with @dmtrKovalenko in mui/material-ui-pickers#1653. |
Current Behavior 😯
When using a controlled autocomplete input, user clicks once to open the menu and selects a value. Then then click off the auto complete to elsewhere on the page. Then the click back on the autocomplete. It does not open. They have to click a second time and then it opens.
Expected Behavior 🤔
When using a controlled autocomplete input, user clicks once to open the menu and selects a value. Then then click off the auto complete to elsewhere on the page. Then the click back on the autocomplete. It opens.
Steps to Reproduce 🕹
https://codesandbox.io/s/romantic-meninsky-kcqgh and here is the code (from autocomplete docs):
Context 🔦
This will prevent me from using autocomplete componnent due to its effect on mobile users.
Your Environment 🌎
The text was updated successfully, but these errors were encountered: