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

[Select] Change popover position #12208

Closed
2 tasks done
w3nda opened this issue Jul 20, 2018 · 14 comments
Closed
2 tasks done

[Select] Change popover position #12208

w3nda opened this issue Jul 20, 2018 · 14 comments
Assignees
Labels
component: select This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement

Comments

@w3nda
Copy link

w3nda commented Jul 20, 2018

  • This is a v1.x issue.
  • 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

@oliviertassinari oliviertassinari added the component: select This is the name of the generic UI component, not the React module! label Jul 20, 2018
@oliviertassinari oliviertassinari self-assigned this Jul 21, 2018
@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 21, 2018

@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.

@oliviertassinari oliviertassinari added the support: question Community support but can be turned into an improvement label Jul 21, 2018
@oliviertassinari
Copy link
Member

oliviertassinari commented Jul 21, 2018

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

@oliviertassinari oliviertassinari changed the title [Select] can't change popover position or disable it's functionallity [Select] Change popover position Jul 21, 2018
@w3nda
Copy link
Author

w3nda commented Jul 22, 2018

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?

@oliviertassinari
Copy link
Member

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.

@Shrikant9
Copy link

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.

@oliviertassinari
Copy link
Member

oliviertassinari commented Mar 4, 2019

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

@Shrikant9
Copy link

Shrikant9 commented Mar 5, 2019

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.

@oliviertassinari
Copy link
Member

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

@itairov
Copy link

itairov commented Jun 14, 2020

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

@oliviertassinari
Copy link
Member

We will likely change the default position with #18493.

@itairov
Copy link

itairov commented Jun 14, 2020

make default it would be very good

@Tasin5541
Copy link

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

How can we do this when using Textfield for Select? it doesn't accept the menuprops

@oliviertassinari
Copy link
Member

@Tasin5541 You can use <TextField SelectProps={}>.

@aleksander351
Copy link

@oliviertassinari
The example is not working with bottom positioned select elements. The menu covers the select.

select-position

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: select This is the name of the generic UI component, not the React module! support: question Community support but can be turned into an improvement
Projects
None yet
Development

No branches or pull requests

6 participants