question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scrolling scrolling menu into view does not work well inside scroll container

See original GitHub issue

Are you reporting a bug or runtime error?

A bug, here is a codesandbox: https://codesandbox.io/s/w0ymoxq827

The issue is that viewHeight is calculated from the window, which causes problems for select elements inside of other scroll containers. This can be seen in the provided codesandbox, by changing the height of the embedded browser window, and seeing that the scroll behavior changes depending on that height.

I’ve played around in the code enough to find what seems to be a solution, causing the scroll container to scroll when needed, and also constraining the height of the menu to the total visible height of the scroll container, so the entire menu is shown, and it’s not necessary to scroll the container outside the menu to see the entire menu. I’ll work on cleaning up my code and will submit a PR, but I wanted to at least open an issue to explain the problem.

Oh and one other question while I’m at it, why does the scroll container need to be position: relative; to be detected as a scroll parent? It’s not immediately obvious that it’s necessary, and it was only by digging through the source that I figured out why my container was not scrolling. I guess this is because the menu is absolutely positioned, so it needs a relative parent.

I believe this is similar to the case reported back in https://github.com/JedWatson/react-select/issues/1267, but that plnkr is broken, so I can’t tell for sure.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:4
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
IanVScommented, Jul 6, 2019

@ranihorev There is now. I finished up the e2e test that I was a bit stuck on, and pushed one up. I hope that it’s valuable and that the maintainers will be able to merge it. 🤞

1reaction
mmarchuk-jamacommented, Jul 2, 2019

Thanks for your comment @IanVS . Setting the scroll container to position: relative; fixed my issue related to menu focus and likely saved me a great deal of time!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scroll View inside view not working react native - Stack Overflow
I am rendering child component which has scrollview and also parent has scrollview. I am not able to properly handle this. Can you...
Read more >
overscroll-behavior - CSS: Cascading Style Sheets | MDN
If you have overscroll-behavior: contain; selected, the outer container will not scroll unless you move your cursor out of the inner container ...
Read more >
Scrolling | Angular Material
Virtual scroll viewports that render nontrivial items may find it more performant to simply append to the list as the user scrolls without...
Read more >
How to Use Scroll Panes - Oracle Help Center
A JScrollPane provides a scrollable view of a component. ... If we didn't restrict the size of the scroll pane's container, the scroll...
Read more >
ScrollView - Android Developers
Scroll view may have only one direct child placed within it. ... Set this if the view will serve as a scrolling container,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found