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

Z-Index Problems?

Open bradennapier opened this issue 10 years ago • 59 comments

image

I had this problem with a default install of react-select ? I can't seem to figure it out, I have spent hours on this. It appears near impossible to get the dropdown to be above everything... perhaps some sort of portal solution should be used for this ?

bradennapier avatar Jul 13 '16 03:07 bradennapier

+1

ufukomer avatar Jul 14 '16 14:07 ufukomer

We fixed this (temporarily, hopefully!) by manually setting a higher index on the Select-menu-outer div.

.Select-menu-outer {
  z-index: 999 !important;
}

theopolisme avatar Jul 14 '16 18:07 theopolisme

This doesnt work for me because I have items in another stacking context which will go over the other divs. A portal solution is needed otherwise it is impossible to guarantee the results of the dropdown not being affected by the other styles.

bradennapier avatar Jul 26 '16 15:07 bradennapier

+1 same problem, jQueryUI elements showing up on top

benjiwheeler avatar Nov 27 '16 18:11 benjiwheeler

I came looking for an answer to that. Found it there, putting it here in case others like me stop at this issue and don't see the other one ;) https://github.com/JedWatson/react-select/issues/1076#issuecomment-253629943

Augustin82 avatar Nov 29 '16 10:11 Augustin82

anyone solved this problem? menuContainerStyle={{ zIndex: 5 }} not work.

evgeniiteterin avatar Feb 13 '17 15:02 evgeniiteterin

:+1: having this issue as well. Neither the suggested Select api

<Select {...props} menuContainerStyle={{'zIndex': 999}} />

nor the css

.Select-menu-outer {
    z-index: 999 !important;
}

worked. Any thoughts would be great!

mduleone avatar Feb 21 '17 23:02 mduleone

See prateekjahead's comment: https://github.com/JedWatson/react-select/issues/1010 "HubSpot's react-select-plus takes in dropdownComponent as a prop which solves the issue."

turnerniles avatar Mar 05 '17 18:03 turnerniles

z-Index did not work for me because I have jQueryUI items. When I set the opacity to 0.99 of the element that contained these items, the dropdown appears in the front.

prototypos avatar Mar 08 '17 14:03 prototypos

I've also tried setting z-index: 999 !important on the div with the .Select-menu-outer class and on subsequent parent divs, but it still doesn't work

NatashaKSS avatar Mar 17 '17 02:03 NatashaKSS

@NatashaKSS Have you tried react-select-plus with the same css?

turnerniles avatar Mar 17 '17 04:03 turnerniles

If anybody can isolate why it works with react-select-plus I'd be very happy to port the fix back upstream :+1:

The explanation on #1010 about being inside a parent element with certain styles applied sounds like it may be the culprit, in which case injecting the menu into the body would be a potential fix, but I'm pretty sure that causes other unexpected behaviours with positioning.

Alternatively if someone can point me at an example I can hack that replicates the issue either @jossmac or I can take a look!

JedWatson avatar Mar 17 '17 05:03 JedWatson

Hey,

I also had an issue with z-index and components not properly displaying. Walking through the code I've noticed that LESS & SCSS versions of variables have different values:

https://github.com/JedWatson/react-select/blob/master/less/select.less#L32 https://github.com/JedWatson/react-select/blob/master/scss/select.scss#L29

I don't know if that is by design or not, @JedWatson? In case of LESS z-index value is set to 1 and in case of SCSS it's set to 1000 !default.

Please remember how z-index really works and z-index is not global for whole site. You should take care of proper nesting in order to work as required. If you need any good explanation, take a look here https://css-tricks.com/almanac/properties/z/z-index/

eat broccoli & workout,

bartekwitczak avatar Mar 28 '17 06:03 bartekwitczak

Hey,

I ran into some some issues with the stacking context as well and I managed to fix them by changing the z-index of open Select elements: .Select.is-open { position: relative; z-index: 1000; }

I don't know if this is the best solution but I hope it can help :)

notten13 avatar Apr 06 '17 09:04 notten13

Hi,

Anyone has fixed this problem ? I've tried every solution i've seen but still no results. I've also tried react-select-plus without any results.

Thanks

mdcorriveau avatar May 01 '17 19:05 mdcorriveau

If you use an animations-lib (e.g. GSAP) it is possible that it adds transform to the style attribute of the node in which you use react-select. As long as that attribute is set setting z-index will not work. In that case you need to remove the transform after your animation is done (Some animation libs support that).

LinuCC avatar May 22 '17 15:05 LinuCC

@bartekwitczak Thanks for your tip!

A bit of reviewing how z-index works and I could solve my problem with this. I'd suggest everyone reading https://css-tricks.com/almanac/properties/z/z-index/

Basically what I needed to do is to set the z-index higher on the parent component, who contained the select, not the select itself. Because it's z-index needed to be greater than his elements "brothers".

schuchowsky avatar Jun 12 '17 21:06 schuchowsky

this worked for me

.Select-menu {
    position: fixed !important;
}

then I had to give fixed width to both the input and the dropdown, here is the css I changed:

.Select {
    width: 444px !important;
    margin-right: 5px;
    z-index: 0 !important;
}

.Select.is-open {
	z-index: 1 !important;
}

.Select-menu {
    position: fixed !important;
    width: 440px !important;
    margin: 1px;
}

mwmcode avatar Jun 30 '17 06:06 mwmcode

My problem was that my select box was the child of an element that was using a transformation (Animate.css to be exact), and that creates a new stack context. Once I got rid of that, react-select played nicely with it's DOM siblings. There are work-arounds for dealing with z-index issues with transformations. Check out this article for some slick css tips.

DavidDionise avatar Aug 02 '17 17:08 DavidDionise

Since there are quite a few answers that handles this, closing this out.

agirton avatar Aug 03 '17 00:08 agirton