Material-ui: [Select] Change popover position

Created on 20 Jul 2018  路  11Comments  路  Source: mui-org/material-ui

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

Expected Behavior


I want to disable the way the select displays the popover, with the selected item being on the select, popover moving weird, just want to disable it, and position the menu under the select permanently.
I've been through Select's files, couldn't find it. if you can walk me through, I'll do it myself and make a PR.

Current Behavior

The popover is moving according to the selected item and there is no disable option / reposition option.

Examples


I want the menu to be under the select.
image

Context

Select question

Most helpful comment

Oh, it's with the Select, let's go one step deeper:

  • The Select is using the Menu:
    capture d ecran 2018-07-21 a 22 04 42
  • 鈾伙笍
      <Select
        MenuProps={{
          anchorOrigin: {
            vertical: "bottom",
            horizontal: "left"
          },
          transformOrigin: {
            vertical: "top",
            horizontal: "left"
          },
          getContentAnchorEl: null
        }}
      >

https://codesandbox.io/s/18l2042y97

All 11 comments

@w3nda Following the documentation:

  • The Menu component is built on top of the Popover:
    capture d ecran 2018-07-21 a 22 00 18
  • The Popover can be positioned as you are expecting:
    capture d ecran 2018-07-21 a 22 01 16
  • Combining these two informations and fixing a warning, we can came up with:
        <Menu
          anchorOrigin={{
            vertical: "bottom",
            horizontal: "left"
          }}
          transformOrigin={{
            vertical: "top",
            horizontal: "left"
          }}
          getContentAnchorEl={null}

https://codesandbox.io/s/9l17k3qnk4

I hope that help.

Oh, it's with the Select, let's go one step deeper:

  • The Select is using the Menu:
    capture d ecran 2018-07-21 a 22 04 42
  • 鈾伙笍
      <Select
        MenuProps={{
          anchorOrigin: {
            vertical: "bottom",
            horizontal: "left"
          },
          transformOrigin: {
            vertical: "top",
            horizontal: "left"
          },
          getContentAnchorEl: null
        }}
      >

https://codesandbox.io/s/18l2042y97

King!
I've found that if the Menu has enough space under it, it will render perfectly, but if he won't have space on screen Menu will be pushed up. true? or broken behavior?

I've found that if the Menu has enough space under it, it will render perfectly, but if he won't have space on screen Menu will be pushed up.

@wenduzer This sounds like the expected behavior.

Oh, it's with the Select, let's go one step deeper:

@oliviertassinari Thanks, this is exactly what I have been searching for past 2 hours.

@Shrikant9 How can we improve the discoverability of the answer?

How can we improve the discoverability of the answer?

@oliviertassinari In my opinion, having more diverse versions of demos on the demo page of <Select /> component. Although honestly, I've recently started using material-ui so still need to get used to the docs.

@Shrikant9 We would be happy to accept a pull request 馃憤.

@oliviertassinari thank you my friend, you helped me very very very much. I know material ui well enough, but I couldn鈥檛 come to this decision

We will likely change the default position with #18493.

make default it would be very good

Was this page helpful?
0 / 5 - 0 ratings

Related issues

amcasey picture amcasey  路  70Comments

damianobarbati picture damianobarbati  路  55Comments

garygrubb picture garygrubb  路  57Comments

chadobado picture chadobado  路  119Comments

kybarg picture kybarg  路  164Comments