Z-Index Problems?

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 ?
+1
We fixed this (temporarily, hopefully!) by manually setting a higher index on the Select-menu-outer div.
.Select-menu-outer {
z-index: 999 !important;
}
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.
+1 same problem, jQueryUI elements showing up on top
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
anyone solved this problem? menuContainerStyle={{ zIndex: 5 }} not work.
:+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!
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."
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.
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 Have you tried react-select-plus with the same css?
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!
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,
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 :)
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
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).
@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".
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;
}
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.
Since there are quite a few answers that handles this, closing this out.