react-select icon indicating copy to clipboard operation
react-select copied to clipboard

dropdowns not going outside of bounding containers

Open wbecker opened this issue 11 years ago • 35 comments

It seems that dropdowns seem to render only within the parent container that the select is in, instead of being on top of the entire page.

I currently have a dropdown in a material-ui card and when it opens up it clips the content.

I have seen other projects position it using "fixed" so that it can live outside the normal flow - at the moment it is "absolute".

wbecker avatar Aug 24 '15 19:08 wbecker

Are there any good work-arounds for this?

I have a select box near the bottom of a form element and the options are cutoff where the parent container ends. It should flow over.

RichardForrester avatar Oct 18 '15 16:10 RichardForrester

+1

solognt avatar Jan 13 '16 10:01 solognt

Anyone have a work-around? Breaks my site as well

dcworldwide avatar Jan 25 '16 02:01 dcworldwide

+1

juan0087 avatar Apr 29 '16 06:04 juan0087

👍

wbprice avatar May 09 '16 18:05 wbprice

The dropdown menu has css position: absolute, so it's bound to the parent container. As a result the dropdown menu changes the height of the parent container which is problematic in some cases, e.g. if the parent container is some kind modal dialog.

In those cases the dropdown menu should mimic the original behavior of selects where it overlaps other elements on the page. In order to achieve this behavior the dropdown menu must have position: fixed and the positioning (top, left, right) must be handled manually. It has to be attached to the position of the select control and the position must be manually change when scrolling the viewport.

I'm curious if this could be achieved by utilizing menuRenderer to draw a custom menu. Maybe a core contributor could point us into the right direction?

winterbe avatar May 18 '16 13:05 winterbe

Anyone have any luck or updates with this? I'm also commenting on a similar issue: https://github.com/JedWatson/react-select/issues/810

maxmatthews avatar May 23 '16 15:05 maxmatthews

My solution was just to add overflow: visible to the parent container (in the case my modal).

maxmatthews avatar May 24 '16 15:05 maxmatthews

my solution would be making it act more like jquery-ui's dropdown, which positions its list of choices outside the component in </body>, with absolute(or fixed?) position.

I accomplish this by extending the Select class and overwriting componentDidUpdate method, check if it just opened new list of choice, and position the list accordingly.

plantvsbirds avatar Jul 21 '16 21:07 plantvsbirds

Is a fix planned for this?

This is a pretty major feature issue for a dropdown replacement… (it is not always possible to change the container to allow visible overflow)

@plantvsbirds would you mind sharing the code for your fix?

zedrdave avatar Dec 06 '16 04:12 zedrdave

Check "react portal". This requires some hack to react-select's render function

Dave [email protected]于2016年12月5日 周一22:15写道:

Is a fix planned for this?

This is a pretty major feature issue for a dropdown replacement… (it is not always possible to change the container to allow visible overflow)

@plantvsbirds https://github.com/plantvsbirds would you mind sharing the code for your fix?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/JedWatson/react-select/issues/404#issuecomment-265056329, or mute the thread https://github.com/notifications/unsubscribe-auth/AF6oJnrsuv22dbTHZcFJ4becULJTt9uuks5rFOFygaJpZM4FxQia .

plantvsbirds avatar Dec 06 '16 04:12 plantvsbirds

+1

gram7gram avatar Jan 11 '17 12:01 gram7gram

The best way would be something like React-Portal, like @plantvsbirds pointed out. This is how I solved it:

https://gist.github.com/kumarharsh/5ada99a2f6b5867984991b70bdc453a1

basically, I used the defaultMenuRenderer from react-select/lib/utils/defaultMenuRenderer, and wrapped it inside a portal...

kumarharsh avatar Jan 17 '17 13:01 kumarharsh

+1

tulbox avatar Jan 26 '17 07:01 tulbox

@JedWatson I'm using react-portal, but in the case when the select has no entries, it shows the placeholder. In this case, the defaultMenuRenderer is not used, but rather a plain div is used. See the relevant code here: https://github.com/JedWatson/react-select/blob/ef3a4687bc67684809c3a2648143a1c325ee987e/src/Select.js#L974

Can some change be made so that the placeholder also uses the defaultMenuRenderer? Without this, it's impossible to prevent the empty select from being cut-off.

kumarharsh avatar Jan 27 '17 08:01 kumarharsh

+1

jwilander avatar Feb 20 '17 18:02 jwilander

+1

cjtafoya avatar Apr 11 '17 15:04 cjtafoya

+1

udaypant avatar Jun 22 '17 04:06 udaypant

+1

ramirez avatar Jun 27 '17 08:06 ramirez

Should be using portals at some point, probably!

https://facebook.github.io/react/docs/portals.html

wbecker avatar Sep 26 '17 17:09 wbecker