Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SelectPicker is moving along with the Scroll #1498

Closed
barmola opened this issue Feb 11, 2021 · 9 comments
Closed

SelectPicker is moving along with the Scroll #1498

barmola opened this issue Feb 11, 2021 · 9 comments
Labels
Answered A question that was resolved with an answer. Use along with "Not an issue" label. component: SelectPicker type: Not an issue Issues that are not actually an issue, e.g. questions. Prefer using discussions.

Comments

@barmola
Copy link

barmola commented Feb 11, 2021

What version of rsuite are you using?

4.8.8

What version of React are you using?

17.0.1

What browser are you using?

Chrome, Firefox

Describe the Bug

SelectPicker Menu is moving up and down along with the Scroll
Screenshot 2021-02-11 at 11 17 58 AM
, Behaving like position:fixed

Expected Behavior

SelectPicker menu should stay relative to its toggle wrapper.

To Reproduce

@simonguo
Copy link
Member

You can set a container prop for SelectPicker. Assigned to the scroll container.
The Menu will be rendered into the container.

<div src={containerRef}>
  <SelectPicker container={()=>containerRef.current}/>
</div>

@mykhailo-space44
Copy link

Have the same issue on "rsuite": "5.6.0"

@simonguo simonguo added the Answered A question that was resolved with an answer. Use along with "Not an issue" label. label Feb 23, 2022
@SevenOutman SevenOutman added type: Not an issue Issues that are not actually an issue, e.g. questions. Prefer using discussions. component: SelectPicker labels Apr 3, 2022
@SevenOutman
Copy link
Member

Hi @barmola, I'm closing this issue as it seems to have been resolved. Feel free to re-open if it's actually not.

@OrnellaSofia
Copy link

Just as a comment, the parent div should have position: relative set. I had been running into this issue and the solution didn't work until I added that.

@yurifw
Copy link

yurifw commented May 6, 2024

Hello, I'm sorry to resurrect this, but the suggested solution doesn't work when the picker is used to select multiple items, for instance, TagPicker or CheckPicker. It works until the user clicks the first item, then if he scrolls before clicking the second item, the container follows the scroll just like the second item. I guess that it has something to do with re-rendering, but I'm not sure. Can someone with this?

@simonguo
Copy link
Member

simonguo commented May 7, 2024

Hi @yurifw .
Please fork this example to reproduce your issue.
https://stackblitz.com/edit/react-wsoi3i

@yurifw
Copy link

yurifw commented May 7, 2024

Thanks for helping!
Here's the fork: https://stackblitz.com/edit/react-wsoi3i-jdaqnx
I think it's related to setting a fixed height and overflow on children, but I'm not sure, kinda lost with this one...

@simonguo
Copy link
Member

simonguo commented May 7, 2024

https://stackblitz.com/edit/react-wsoi3i-jdaqnx

You should use useRef instead of createRef to get the reference of the element. createRef will return a new reference every time it renders, while useRef will return a fixed reference.

-  const scrollContainer = createRef();
+  const scrollContainer = useRef();

@yurifw
Copy link

yurifw commented May 7, 2024

So much time trying to solve this... Thanks a lot, worked perfctly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Answered A question that was resolved with an answer. Use along with "Not an issue" label. component: SelectPicker type: Not an issue Issues that are not actually an issue, e.g. questions. Prefer using discussions.
Projects
None yet
Development

No branches or pull requests

6 participants