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

Dropdown remains fixed in place and doesn't scroll with parent container

Open bladey opened this issue 6 years ago • 61 comments

This issue is a round-up of multiple past issues documenting the same bug. Feel free to check out the linked issues below for more information. This issue is the source of truth going forward to investigate the issue, report findings, and implement a bug fix.

Issue:

Screen Capture on 2020-06-15 at 14-43-03

Dropdown remains fixed in place and doesn't scroll with parent container.

The commit responsible for this issue is located here - https://github.com/JedWatson/react-select/commit/691a01171969da89e20097f9d603651bb18a8510

Version v3.0.4 does not have this bug however the latest release v3.1.0 does.

Issues:

https://github.com/JedWatson/react-select/issues/4554 https://github.com/JedWatson/react-select/issues/4020 https://github.com/JedWatson/react-select/issues/4052 https://github.com/JedWatson/react-select/issues/3734 https://github.com/JedWatson/react-select/issues/4085 https://github.com/JedWatson/react-select/issues/3929 https://github.com/JedWatson/react-select/issues/3349 https://github.com/JedWatson/react-select/issues/3646

Examples:

https://codesandbox.io/s/react-select-v3-sandbox-forked-lgkms https://codesandbox.io/s/compassionate-cookies-85j2n https://codesandbox.io/s/react-select-v3-sandbox-kr5wf https://codesandbox.io/s/festive-dirac-izf5y https://codesandbox.io/s/react-codesandboxer-example-xy47y

If anyone would like to share any further information, please do so.

bladey avatar Jun 15 '20 04:06 bladey

Hi - for info, I have explicitly tested this by installing v3.0.4 and v3.0.3, and I experience the same issue in both versions. Is it possible that the bug existed even before the commit that you have highlighted above?

mjb95 avatar Jun 15 '20 08:06 mjb95

I think @mjb95 is right, as this is the behaviour of React Select in v2 also; menuPosition fixed & portal, both do not update the positioning of the Menu on scroll - so the menu is stuck. All the sanboxes here have menuPosition fixed, and portal, and nothing related to it was changed in that commit.

The bug mentioned by @bladey is related to a workaround (menuShouldBlockScroll) to handle the issue of the menu not scrolling - as mentioned in this comment https://github.com/JedWatson/react-select/issues/3929#issuecomment-604866966.

This sandbox demonstrates that bug it better: on opening the menu, the scroll stops working completely. https://codesandbox.io/s/elegant-sky-51tlo?file=/src/App.js

@bladey I suggest we separate these issues, as menuShouldBlockScroll is a completely separate issue, would not be fix this problem (& it should be done anyway).

This would only be solved if something like tether.js is pulled into the lib (which has been proposed before) #810 is directly related to this (and all others, except #3929), & has most of the problems/solutions related in one place - and IMO it is still not resolved. (see a hacky solution in this comment, which extends the Select class and uses react-tether + react-dimensions: https://github.com/JedWatson/react-select/issues/810#issuecomment-398563946)

palashkaria avatar Jun 25 '20 13:06 palashkaria

Hi @bladey Could you please let us know if this would be prioritised and made available in next patch release please.

srinivasmerugu avatar Jul 09 '20 13:07 srinivasmerugu

@srinivasmerugu we'll get to it as soon as we can, any updates will be provided here.

bladey avatar Jul 16 '20 05:07 bladey

Hi, has any progress been made on this issue?

mjb95 avatar Jul 30 '20 10:07 mjb95

Hi, anyone has any update on this? In my case, it's happening in the Chrome-75 version but not in 78 or 80 versions.

lohithvecham avatar Sep 21 '20 07:09 lohithvecham

Hi, anyone has any update on this? In my case, it's happening in the Chrome-75 version but not in 78 or 80 versions.

i see it happening in chrome 85. when do you think it will fix?

HodayaGruz avatar Sep 24 '20 11:09 HodayaGruz

how much time it take to push this commit?

narojisivamurthi1230 avatar Nov 05 '20 13:11 narojisivamurthi1230

~~I've started a fork of react-select. Feel free to resubmit this issue on the fork and/or submit a PR to resolve this issue on the fork and we can get it merged and released.~~

EDIT: :tada: I've archived the fork now that we've got some momentum in this repo and Jed is involved again. Sorry for the disturbance!

Methuselah96 avatar Nov 14 '20 16:11 Methuselah96

Are you guys changing the menuPortalTarget? I ran into this issue because I was using menuPortalTarget so the dropdown would display outside of my modal. I found out that the problem was because I was using document.body as my target but it was in fact my modal, not the body, that was scrolling. Using my modal as the target instead of document.body fixed the issue for me.

colin-oos avatar Nov 19 '20 18:11 colin-oos

@colin-oos How do you target a specific element? I have a div that I want to use as my target, how would I reference it?

MenachemICTBIT avatar Nov 24 '20 12:11 MenachemICTBIT

Same issue here, got a lot of modals with height bigger than my screen (added overflow: scroll) - when do you think it'll be fixed?

qenibas avatar Nov 27 '20 10:11 qenibas

@colin-oos How do you target a specific element? I have a div that I want to use as my target, how would I reference it?

You could use a React Ref or if you give your div an id then you can use javascript document.getElementById('my-divs-id') and pass that result into menuPortalTarget. If you use a react ref, I believe you'd need to pass this.myDivsRef.target into menuPortalTarget (I haven't actually tried with a react ref though)

colin-oos avatar Nov 30 '20 15:11 colin-oos

@bladey How is it going? It's been very serious issue.....

BlackNightFury avatar Dec 08 '20 17:12 BlackNightFury

This is bad. No way i could out a way to fix this. Can someone help please.

umanga907 avatar Dec 16 '20 16:12 umanga907

Here's what I've been using. It's really hack-y and caused other problems, but it's the best I could do.

Because the position is fixed, if you need to scroll , the menu is pinned to the fixed position. The trick was to add an event listener that checks where the scroll occurs, and closes the menu if scrolling outside. The major problem this caused was, since it's used on a data table, the entire table rerenders every time you scroll, causing major stuttering. If your use case is more like a side menu, it might work.

I ended up using a different dropdown, in large part, because of this issue.

<Select isClearable value={value || ''} menuPortalTarget={document.body} menuPosition={'fixed'} // HACK: Specifying class name to force close dropdown. Issue with react-select libray (dropdown fixed position). // This CSS selector will almost certainly cause problems during deployment. closeMenuOnScroll={(e: any) => !e.target.classList.contains('css-4ljt47-MenuList')} options={suggestions} />

MenachemICTBIT avatar Dec 16 '20 16:12 MenachemICTBIT

@bladey How is it going? Could you please provide an update on this. Issue still present in latest versions.

srinivasmerugu avatar Jan 05 '21 09:01 srinivasmerugu

We're not able to use any positioning other than fixed without it mangling our app by shifting the page upwards and offscreen, but using fixed we see this issue.

@Methuselah96 is there any plan to address this? I see it's been removed from any milestones? I really hope this can get fixed. I spent 6 hours trying to work around this issue without any success whatsoever, or even clues about how to fix it besides relying on fixed positioning - which has its own issues like this.

Nantris avatar Jan 23 '21 21:01 Nantris

Greetings @Slapbox ,

Part of the version 4 release included a refactor of the scrollCaptor and menuPositioning into a single scrollManager. We have also added a menu label to the existing PR's which address menu behavior so that we can address them holistically instead of ad hoc.

I'm currently focused on addressing some of the underlying accessibility gaps with the aria live implementation, but hope to focus on the menu issues right after.

ebonow avatar Jan 23 '21 21:01 ebonow

@Slapbox What's your use case? Are you using it in a modal? What are you using for menuPortalTarget? If you could create a CodeSandbox detailing your specific problem that would be the most helpful. ~Many of the issues described above have to do with setting the menuPortalTarget to document.body when the body is not the element that's actually scrollable.~ (I was misunderstanding the problem when I said this.)

Methuselah96 avatar Jan 23 '21 21:01 Methuselah96