Material-ui: Shrink InputLabel wrong css when displayEmpty with Select outlined

Created on 11 Jun 2020  路  3Comments  路  Source: mui-org/material-ui


When I set InputLabel with shrink={true} and FormControl is outlined, The InputLabel background is not correct

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

Current Behavior 馃槸

The background of InputLabel (shrink={true}) when use FormControl (variant="outlined") is transparent ( not 'white' as expected )

Expected Behavior 馃

When I use InputLabel ( shrink={true} ) when use FormControl ( variant="outlined" ), the background of InputLabel shoud be 'white'

Steps to Reproduce 馃暪

Steps:
Link Codesandbox: https://codesandbox.io/s/material-demo-4dtlw

  1. Choose default option
  2. Lose focus to the select
  3. The InputLabel background is transparent ( not 'white')

image

Context 馃敠


I trying to use shrink={true} and variant="outlined" with the Select, but the css is not correct.

Your Environment 馃寧

| Tech | Version |
| ----------- | ------- |
| Material-UI | v4.10.0 |
| React | v16.8.6 |
| Browser | |

TextField support

Most helpful comment

After a few hours of frustration I finally found the (hopefully correct) solution:

<FormControl variant="outlined">
  <InputLabel shrink>{label}</InputLabel>
  <Select input={<OutlinedInput notched label={label} />} />
</FormControl>

I suggest adding such an example to the documentation, considering I found dozens of issues and/or questions related to the same problem, with no actual working answer though.

This is really confusing especially for someone who just started using material-ui - why it's needed to pass label prop explicitly to OutlinedInput, when we already passed it to FormControl and InputLabel (and it didn't change a thing)...

All 3 comments

馃憢 Thanks for using Material-UI!

We use GitHub issues exclusively as a bug and feature requests tracker, however,
this issue appears to be a support request.

For support, please check out https://material-ui.com/getting-started/support/. Thanks!

If you have a question on StackOverflow, you are welcome to link to it here, it might help others.
If your issue is subsequently confirmed as a bug, and the report follows the issue template, it can be reopened.

@thaind97git You need to tell the select that the notch should be "open".

After a few hours of frustration I finally found the (hopefully correct) solution:

<FormControl variant="outlined">
  <InputLabel shrink>{label}</InputLabel>
  <Select input={<OutlinedInput notched label={label} />} />
</FormControl>

I suggest adding such an example to the documentation, considering I found dozens of issues and/or questions related to the same problem, with no actual working answer though.

This is really confusing especially for someone who just started using material-ui - why it's needed to pass label prop explicitly to OutlinedInput, when we already passed it to FormControl and InputLabel (and it didn't change a thing)...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zabojad picture zabojad  路  3Comments

ericraffin picture ericraffin  路  3Comments

revskill10 picture revskill10  路  3Comments

finaiized picture finaiized  路  3Comments

mb-copart picture mb-copart  路  3Comments