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

Adding AutoComplete in Dialog breaks rendering outside and inside Dialog #18576

Closed
2 tasks done
NixBiks opened this issue Nov 26, 2019 · 2 comments · Fixed by #18578
Closed
2 tasks done

Adding AutoComplete in Dialog breaks rendering outside and inside Dialog #18576

NixBiks opened this issue Nov 26, 2019 · 2 comments · Fixed by #18578
Labels
bug 🐛 Something doesn't work component: autocomplete This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.

Comments

@NixBiks
Copy link
Contributor

NixBiks commented Nov 26, 2019

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

This issue might be related to #18082 but I am not sure.

Working

If I have a Dialog component without AutoComplete components inside then my AutoComplete in the main content looks fine, see first two images.

Screenshot 2019-11-26 at 11 00 44

Screenshot 2019-11-26 at 11 00 36

Not working

If I add AutoComplete components to my Dialog component then all AutoComplete components starts looking weird.

Screenshot 2019-11-26 at 10 54 55

Screenshot 2019-11-26 at 10 54 44

Your Environment 🌎

Tech Version
Material-UI v4.6.1
React v16.11.0
Browser Version 78.0.3904.97
TypeScript v3.6.4
Material UI lab v4.0.0-alpha.32

Let me know if I need to provide additional information

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: autocomplete This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process. labels Nov 26, 2019
@oliviertassinari
Copy link
Member

@mr-bjerre Thanks for the report. I have seen this problem happen a couple of times already. It's a CSS injection order issue. You would need to import TextField before Autocomplete. However, I think that we should solve this problem in the core. We could increase the specificity on the conflicting rules:

diff --git a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
index bd6f52c52..cbf86bdc5 100644
--- a/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
+++ b/packages/material-ui-lab/src/Autocomplete/Autocomplete.js
@@ -30,9 +30,6 @@ export const styles = theme => ({
   inputRoot: {
     flexWrap: 'wrap',
     paddingRight: 62,
-    '& $input:not(:first-child)': {
-      paddingLeft: 4,
-    },
     '&[class*="MuiOutlinedInput-root"]': {
       padding: 8,
       paddingRight: 62,
@@ -57,14 +54,19 @@ export const styles = theme => ({
         right: 7,
       },
     },
+    '& $input:not(:first-child)': {
+      paddingLeft: 4,
+    },
+    '& $input': {
+      width: 0,
+      minWidth: 30,
+    },
   },
   /* Styles applied to the input element. */
   input: {
-    width: 0,
-    minWidth: 30,
     flexGrow: 1,
-    opacity: 0,
     textOverflow: 'ellipsis',
+    opacity: 0,
   },
   /* Styles applied to the input element if tag focused. */
   inputFocused: {

Would that work for you? Do you want to submit a pull request? :)

@NixBiks
Copy link
Contributor Author

NixBiks commented Nov 26, 2019

Cool thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: autocomplete This is the name of the generic UI component, not the React module! good first issue Great for first contributions. Enable to learn the contribution process.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants