Material-ui: MenuItems are not fullWidth if TextField is fullWidth

Created on 21 Feb 2018  路  9Comments  路  Source: mui-org/material-ui

  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

If a TextField is set to fullWidth and used as a Select, the MenuItems should be as wide as the input (and Menu).

Current Behavior

The Menu is the same width as the TextField, but the MenuItems are not the correct size.

image_1024

Steps to Reproduce (for bugs)

<TextField fullWidth select  label="Days and Stuff">
    <MenuItem value={0}>Today</MenuItem>
    <MenuItem value={1}>24 Hours</MenuItem>
    <MenuItem value={7}>7 Days</MenuItem>
    <MenuItem value={15'}>15 Days</MenuItem>
    <MenuItem value={30}>30 Days</MenuItem>
</TextField>

Context

This just looks wonky - its not critical but people think our app is broken. In the meantime, I've used the native prop to skirt around the issue.

Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | beta 33 |
| React | 15.x |
| browser | Chrome / FF |
| etc | |

TextField incomplete

Most helpful comment

Another alternative is to use an override on the List component, i.e:

MuiList: {
      root: {
        width: '100%',
      },
    },

All 9 comments

This can be used as a workaround:

<TextField fullWidth select SelectProps={{ MenuProps: { MenuListProps: { style: { width: '100%' } } } }}>

Another alternative is to use an override on the List component, i.e:

MuiList: {
      root: {
        width: '100%',
      },
    },

Not sure if this was fixed already but could not reproduce with chrome / FF
https://codesandbox.io/s/nwy21nll

@oliviertassinari This seems to be fixed: https://codesandbox.io/s/zq7qj3p86x

@joshwooding do you happen to know which version included the fix?

@joshwooding Thank you for looking into it :).
@cvburgess You can try to change the version in the linked codesandbox. I have tried up to v1.0.0, it's working. If you want to stay on the beta, you can dive even further.
v1.0.0-beta.33 is 10 month old, wow, that's all?!

Actually, it's also working with beta.33 馃槷: https://codesandbox.io/s/zq8koqyxy4. If you guys have a reproduction witht the latest version of Material-UI, we can have a look. Otherwise, let's keep it close.

@oliviertassinari we're on 1.5.1 :/

@cvburgess Looks like it works for 1.5.1 too :/ https://codesandbox.io/s/oxzmqylj46
This is just a standalone component though, do you have an example of the outer component and its styling?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chris-hinds picture chris-hinds  路  3Comments

pola88 picture pola88  路  3Comments

sys13 picture sys13  路  3Comments

ryanflorence picture ryanflorence  路  3Comments

TimoRuetten picture TimoRuetten  路  3Comments