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

menuShouldScrollIntoView does not scroll all menu into view

Open fyodor-e opened this issue 4 years ago • 3 comments

React-select with menuShouldScrollIntoView set to true does not scrolled into view properly. Although menu is scrolled into view, last options are still invisible.

On the screenshot below, only option 1 to 4 is visible and options 5 and 6 are not. Parent size is expanded to accommodate full menu and parent can be scrolled manually to see full menu.

image

Sandbox is here https://codesandbox.io/s/reactselectscrollintoview-44b7n

To reproduce:

  1. Make sure, that react select is located at the very bottom of the window, Just above the footer. There should be no empty space between react-select and footer. (it may be required to decrease browser window size)
  2. Open react-select.
  3. Observe, that although container has been scrolled down, it is not scrolled down enough to include all options. To see last options, manual scrolling of the container is required.

Expected result: container is scrolled to accommodate all options.

Also, if header and footer will not be present, parent will be scrolled properly.

fyodor-e avatar Jun 01 '21 00:06 fyodor-e

You can check this solution. Hope it works for you 💚

ChristianCastillejo avatar Jun 16 '21 15:06 ChristianCastillejo

You can check this solution. Hope it works for you 💚

Work for me! Thank you!

luizpaulo165 avatar Sep 23 '21 13:09 luizpaulo165

For the future people. menuShouldScrollIntoView doesn't always work, especially if there is a re-render. To fix this, memoize the value and options props when adding menuShouldScrollIntoView.

irshathcodes avatar Oct 10 '24 12:10 irshathcodes