-
-
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
Width of TextField does not take label into account when no value #16847
Comments
I saw a similar issue here - #12255 - but I believe that this is not a duplicate because it shows issues even with short labels, especially for select |
@klis87 I think that the root issue is the same, the label displays independently from the input element. You need to make sure that: 1. the input has its own size, 2. the label is smaller than the input. |
@oliviertassinari thx for the answer. However, the problem is that I have autogenerated form with WYSIWIG content and I cannot predict labels. What I tried is to disable floating label for those inputs with InputLabelProps={{
shrink: true
}} but then inputs are overlapping - https://codesandbox.io/s/create-react-app-qyeyc Is this intended or this is another issue? If yes I could raise as a new one. |
Then you probably need to truncate the label after x characters. I'm not aware of any better solution. |
@oliviertassinari Ok I will think of sth. I am wondering about this |
@oliviertassinari apologies for spamming you like that in this topic, but I checked this once more and it is not shrink issue, but see https://codesandbox.io/s/create-react-app-qyeyc once again it seems that there is sth wrong with TextField in again, I can raise it a a separate issue if this is a bug |
This is the same underlying limitation. The label is rendered in a position absolute, it escape the rendering flow of your page. |
This I understand, but why it breaks in |
Notice that in example I gave you I set shrink to true which actually causes input width to be dependent on label length. The only problem is overlapping between separate inputs, with shrink: true and fullWidth: false input width is calculated correctly. |
I don't understand, they all look broken. |
@oliviertassinari hmm, I will just send you pictures, so it will more more clear. |
Again: #16847 (comment) |
I hope you are not starting to get frustrated, pls bear with me ;) Just please explain to me why 1st image is fine and 2nd image is not fine, the only difference is |
@klis87 The label doesn't impact the layout, the input does. The |
@oliviertassinari now I get it, indeed for even longer label it does not work even when |
@klis87 I'm wondering how we could document this limitation. |
@oliviertassinari I saw this but I think that this is sth else than label position limitation (especially that shrink: true does not help). I think it would be worth adding also another limitation, that label is positioned absolutely like you mentioned and that input width is independent on label width, which is especially important when fullWidth: false. |
Agree. |
Expected Behavior 🤔
When
fullWidth
isfalse
,TextField
should take label into account in width calculation. It does so but only when value is not empty. This is especially true for select mode, when initial width is super narrow.Current Behavior 😯
Width is not calculated properly as explained above
Steps to Reproduce 🕹
Link: https://codesandbox.io/s/create-react-app-qyeyc
Context 🔦
n/a
Your Environment 🌎
The text was updated successfully, but these errors were encountered: