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

Dropdown is getting overlapped by second react-select.

Open Jaikant opened this issue 9 years ago • 33 comments

Hey guys, I have now been struggling for a few hours. I am having two react-select components. The dropdown from the component on top is getting overlapped by the below component.

I added a z-index of 999 to .Select-menu-outer, but it doesn't change anything. I have attached a screenshot of the issue.

screen shot 2017-02-07 at 4 29 22 pm

Jaikant avatar Feb 07 '17 10:02 Jaikant

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

evgeniiteterin avatar Feb 13 '17 15:02 evgeniiteterin

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

By the way, zIndex doesn't has any effect on position: static elements

MaxInMoon avatar May 30 '17 07:05 MaxInMoon

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

v1.2.1

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

worked for me

brianarpie avatar Jul 09 '18 15:07 brianarpie

Any update on getting this resolved?

lounsbrough avatar Feb 28 '19 19:02 lounsbrough

@lounsbrough, this is worked for me:

v2.4.2 const selectStyles = { menu: styles => ({ ...styles, zIndex: 999 }) };

d3mp avatar Mar 28 '19 15:03 d3mp

@d3mp, yes, we implemented something like this and it's working in our environment.

Thanks.

lounsbrough avatar Mar 29 '19 03:03 lounsbrough

@d3mp is right. You need to target the element that has the absolute style, which is the menu.

juliankigwana avatar Apr 05 '19 14:04 juliankigwana

@d3mp thanks, this works! Use it like:

const selectStyles = { menu: styles => ({ ...styles, zIndex: 999 }) };
<Select styles={selectStyles} />

benkindt avatar Jun 21 '19 11:06 benkindt

@d3mp thanks, this works! Use it like:

const selectStyles = { menu: styles => ({ ...styles, zIndex: 999 }) };
<Select styles={selectStyles} />

worked for me

Luke-Markham avatar Nov 29 '19 07:11 Luke-Markham

This issue was made in 2017, and still is a issue? None of the solutions above works. The dropdown menu is hidden behind other components. CSS, selectstyles og portal-component was not successful.

image

sensei900q avatar Feb 20 '20 08:02 sensei900q

Same here. Menu is still falling behind.

Jonny-B avatar Feb 21 '20 17:02 Jonny-B

@simonkaspersen @Jonny-B which version of react-select are you using?

Would you be able to create a codesandbox that replicates the behaviour? Would be easier to help if there's a code example in a codesandbox.

Also, you can try portalling as suggested here — https://github.com/JedWatson/react-select/issues/3263#issuecomment-445809701

flexdinesh avatar Feb 21 '20 23:02 flexdinesh

@flexdinesh Have tried with the 3 last versions.

Will try. I am currently writing away some of the react-select-boxes

sensei900q avatar Feb 24 '20 13:02 sensei900q

So I needed a combination of:

menuPortalTarget={document.querySelector('body')}

and:

const selectStyles = {
    menuPortal: base => ({ ...base, zIndex: 9999 }),
    menu: provided => ({ ...provided, zIndex: "9999 !important" })
};

<Select 
    styles={selectStyles}
/>

sensei900q avatar Feb 24 '20 14:02 sensei900q

Default behaviour is correct, please see this CodeSandbox.

jossmac avatar Feb 25 '20 23:02 jossmac

After seeing the half dozen related issues, yet not finding a resolution, I have found one.

<Select menuPortalTarget={document.body} menuPosition={'fixed'} />

Add these two options to your Select component.

It appears to make us of the new React Portal feature.

MenachemICTBIT avatar Nov 23 '20 17:11 MenachemICTBIT

Thanks @MenachemICTBIT I Was struggling with the same without finding any satisfactory solution, this worked like a charm!

jperestrelo avatar Dec 02 '20 21:12 jperestrelo

@jperestrelo Glad to hear it. I really struggled with this one as well.

The next problem then becomes that, since the menu is position:fixed, if you need to scroll the page the menu won't scroll with you. I managed a slight hack where I added an event listener that closes the menu when you scroll outside the menu itself (allowing scrolling inside the menu).

MenachemICTBIT avatar Dec 03 '20 07:12 MenachemICTBIT