-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Clicking on an item using Custom Menu scrolls to top #5935
Comments
Not sure if you fixed this already, but in case anyone is wondering: you can prevent unnecessary rerenders that causes this behaviour by making sure you define your rendering components outside the scope of rendering the Select.
see https://react-select.com/components#defining-components example:
|
Hi @imwaihon |
Your This is a bit confusing due to a lack of clearcut examples but you can use the Sample rough example with a 'testProp'
My guess is that this works because of https://legacy.reactjs.org/docs/higher-order-components.html#dont-use-hocs-inside-the-render-method the diffing algorithm. |
If this still does not work, we can consider storing a ref to the previous scrollPosition for each Select |
Thanks for using react-select!
If you are going to ask a question or want to propose a change or a new feature, then please don't file an issue for this.
Questions and feature requests have their own place in our discussions section.
Are you reporting a bug or runtime error?
I am building out a suggestions list to show the user what options they can select in a multiselect. However, when I click on an item, it scrolls to top.
https://playcode.io/1944459
Select any 3 items from Dropdown 1, they will be shown as suggestions for dropdown 2. In dropdown 2, select the last item in the list. Notice that the menu gets scrolled to top. I want to maintain the scroll position. Please advice.
The text was updated successfully, but these errors were encountered: