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][ variant=filled|outlined] can not click label to get input field focus (v3.1.1) #12997

Closed
2 tasks done
TheRealArlie opened this issue Sep 25, 2018 · 9 comments · Fixed by #30493
Closed
2 tasks done
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

@TheRealArlie
Copy link

  • 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

Clicking the label should give the input focus to the underlying input field.

Current Behavior

Clicking the label only marks the label text.

material_ui_bug_3_1_1

Steps to Reproduce

Link: https://codesandbox.io/s/o5qyjywl35

  1. click on label

Context

I tried to use the new outlined variant of the TextField component.

Your Environment

Tech Version
Material-UI v3.1.1
React 16.5.2
Browser Chromium 69 / Firefox 62
@eps1lon
Copy link
Member

eps1lon commented Sep 25, 2018

https://github.com/mui-org/material-ui/blob/7d2fadfc7b90c958d10ef89a0a3ce58cc7ff939e/packages/material-ui/src/InputLabel/InputLabel.js#L41-L46
is causing the issue. I don't know why the yellow background is only an issue for filled or outlined though.

zIndex was added because of #12890 in #12926.

@oliviertassinari oliviertassinari added bug 🐛 Something doesn't work component: text field This is the name of the generic UI component, not the React module! labels Sep 25, 2018
@oliviertassinari
Copy link
Member

@TheRealArlie You can workaround the problem by providing an id (it will link the input with the label). I'm also worried about the hover state to being applied.

@oliviertassinari oliviertassinari added the good first issue Great for first contributions. Enable to learn the contribution process. label Sep 27, 2018
@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 27, 2018

Ok, I had a look at the MCW and vuetify implementations. They are both solving the problem with pointer-events: none;. The downside is that it's preventing users from selecting the label text. On the other hand, the implementation overhead is very small. I think that it's a nice tradeoff. I'm happy to apply it here too. We can add this style in:
https://github.com/mui-org/material-ui/blob/51bb15c6a909d8bbd6e09bc424b9dbb246228620/packages/material-ui/src/InputLabel/InputLabel.js#L41
and
https://github.com/mui-org/material-ui/blob/51bb15c6a909d8bbd6e09bc424b9dbb246228620/packages/material-ui/src/InputLabel/InputLabel.js#L59

@TheRealArlie Do you want to work on this? :)

@eps1lon
Copy link
Member

eps1lon commented Sep 27, 2018

@oliviertassinari That is very often an immediate turn of for me if I can't select text on a website. Can't we revisit the original fix for firefox autofill and make it right?

@oliviertassinari
Copy link
Member

oliviertassinari commented Sep 27, 2018

I don't know why the yellow background is only an issue for filled or outlined though.

@eps1lon It's because the input doesn't overlap the label in the "standard" variant.

Can't we revisit the original fix for firefox autofill and make it right?

I'm out of options here. If you see a better way I would love to learn it.

@byronluk
Copy link
Contributor

byronluk commented Sep 28, 2018

Hey @oliviertassinari is it cool if I work on this? I'll try looking to see if there's a better solution.

@byronluk
Copy link
Contributor

So it seems like your right, the default behavior on the original TextField wouldn't allow users from selecting the label text anyways. But either way the label text can be selected by dragging the cursor from outside the element over into the input.

@I-O-O-I
Copy link

I-O-O-I commented Sep 28, 2018

+1

Maybe try "pointer-events: none;" on label in PR?
(not me)

@oliviertassinari
Copy link
Member

@byronluk Yes, please go ahead :)

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

Successfully merging a pull request may close this issue.

5 participants