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

[TextField] Chromes auto-fill covers label for outlined TextField #12890

Closed
2 tasks done
PutziSan opened this issue Sep 17, 2018 · 8 comments
Closed
2 tasks done

[TextField] Chromes auto-fill covers label for outlined TextField #12890

PutziSan opened this issue Sep 17, 2018 · 8 comments
Labels
bug 🐛 Something doesn't work component: text field 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

@PutziSan
Copy link

image

  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

The yellow background inserted by chromes auto-fill should not cover the label.

Current Behavior

Chromes auto-fill covers the label

Steps to Reproduce

Link: https://material-ui.com/demos/text-fields/#outlined

  1. use chromes auto-fill

Your Environment

Tech Version
Material-UI v3.1.0
React (your react-version from documenation-code ;) )
Browser Google Chrome 69.0.3497.92

possible solution

If I add z-index: 1 to the label, the problem is solved. Another option is to use the CSS-webkit-autofill-selector, but I am not sure which properties you have to change to make it fit

@PutziSan
Copy link
Author

It also happens with filled TextField:

image

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

oliviertassinari commented Sep 17, 2018

If I add z-index: 1 to the label, the problem is solved.

@PutziSan Thanks for raising! My bad, I have removed this logic. I think that it's generic enough to add it in the InputBase.
abc8be8#diff-347c7dd040c46d0783e8c172e42e3dc1L47

@oliviertassinari
Copy link
Member

@PutziSan
Copy link
Author

Okay, cool, I'll send a PR.

If there appears further problems in another browser or if the z-index in the label breaks the layout of some users, there are 2 alternatives (I just thought of it and write it down for documentation):

We could swap the order of the input and label components. Since the label is then drawn after the input element, it appears above the yellow background. => changing this lines to:

// ...
select ? (
  <Select value={value} input={InputElement} {...SelectProps}>
    {children}
  </Select>
) : (
  InputElement
)}
{label && (
  <InputLabel htmlFor={id} ref={this.labelRef} {...InputLabelProps}>
    {label}
  </InputLabel>
)}

We could also leave the input field only as big as it really is and give the container the height/padding. This would look like this (quick&dirty adapted in the browser, doesn't look perfect as it should):
image

@oliviertassinari
Copy link
Member

If there appears further problems in another browser or if the z-index in the label breaks the layout of some users

Do you have an example?

@PutziSan
Copy link
Author

Custom PopOver-implementations with zIndex: 1. Of course this is more of a theoretical case, but possible ;)

https://codesandbox.io/s/xo6jqkr5op (the zIndex: 1-fix for labels is applied via the textField-class in this example)

@PutziSan
Copy link
Author

material-components-web has also placed the label under the input field, whether it is exactly for this reason or for another, is of course hard to say ;)

I think, however, that the zIndex: 1-fix will not bother virtually anyone. I just thought about other possible consequences. If you don't say anything else I would adjust and push it with zIndex: 1 now.

@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 18, 2018

@PutziSan I'm fine with the z-index, thanks for raising the issues. With that in mind, better put the style in the filled and outlined rules of the InputLabel than in the formControl.

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: text field 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

No branches or pull requests

2 participants