zIndex on document.body (dropdown)
See original GitHub issueIs there a way that we can assign a class inside menu container? Currently I used below code to open dropdown and attach to body.
menuPortalTarget={document.body}
the problem for this is the init div (dropdown) z-index is 1 by default and class name default is something css-*(randomly). I wonder that I can just assign my own class something similar like classNamePrefix ?
The issue now is dropdown menu is hidden on modal popup. I was trying to change the zIndex but have no solution yet.
Please advise, thanks
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
How to change zIndex in react-select drowpdown
Add these lines in your all Select tag: <Select // other props menuPortalTarget={document.body} styles={{ menuPortal: base => ({ ...base, ...
Read more >Diagnosis: z-index (submenu hidden behind content)
jQuery/javascript errors ... [+] Submenus (dropdowns) not displaying ... The z-index property of an element determines how an element will be layered ...
Read more >z-index - CSS: Cascading Style Sheets - MDN Web Docs
The z-index CSS property sets the z-order of a positioned element and its descendants or flex items. Overlapping elements with a larger ...
Read more >HTML DOM Style zIndex Property - W3Schools
The zIndex property sets or returns the stack order of a positioned element. An element with greater stack order (1) is always in...
Read more >Z-Index Problems: My buttons show up on top of my dropdown ...
document.getElementById("desc"+i.toString()).innerHTML = "Taken On:"+imagedescriptions[(4*pageIndex)+i-1];. document.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
From their example of portalling you can pass styles to the menuPortal component, see here
styles={{ menuPortal: base => ({ ...base, zIndex: 9999 }) }}
Full component example:
Since we only need the zIndex to be high when the component is focused, use a conditional styling for the container. Otherwise if you happen to have multiple <Select /> components (or other components requiring a high zIndex) it might cause problems if all of them have the same 999 zIndex.