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.

WindowScroller setting incorrect scrollTop after resizing window height

See original GitHub issue

I updated the version of WindowScroller for one of my projects today from 8.8.1 to the current version (8.11.0) and noticed this bug. More details about the use cases and the specifics of the bug below.

To reproduce

To reproduce the bug:

  • Set up WindowScroller without specifying the new scrollElement prop (i.e. you want it to use window). My use case uses a Grid inside WindowScroller, but I think a similar issue would occur with other components.
  • Scroll the page. scrollTop is set as expected at this point and everything works well.
  • Scroll the page down far enough that the top of the container (i.e. element for your Grid or other component inside the WindowScroller) is off the top of the viewport.
  • Resize the height of your browser window.
  • Scroll the page. scrollTop is incorrectly set and the Grid behaves weirdly because it has the wrong scroll value.

I took a quick look at the project’s WindowScroller demo and see similar “weird” behavior when I follow these steps, so hopefully that will be an easy example to work from.

Suspected cause

After looking at the changelog and some of the related source code, I suspect this bug came in with the support for a custom target element in v8.10.0. I’m guessing the problem lies in getPositionFromTop and how it is handling the calculations for the window use case.

Additional details:

I rolled back to my previous version (8.8.1) and verified this bug does not exist there.

Browser: Chrome 55 on OSX 10.11

Use case in my code: Grid inside a WindowScroller that only uses WindowScroller for vertical scrolling per the documentation that says it should not be used for horizontal scrolling.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
andrewbranchcommented, Jan 19, 2017

Yeah, I’m already on it. Will have a PR shortly.

0reactions
bvaughncommented, Jan 20, 2017

Fix released in version 8.11.1. Thanks for the detailed bug report @juliepagano! And thanks for the quick fix @andrewbranch! ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Width of the Table in AutoSizer and Window Scroller is not ...
I am having an issue when the browser is resized. This is my code: render() { return ( <WindowScroller> {({ height, isScrolling, scrollTop...
Read more >
Window sizes and scrolling - The Modern JavaScript Tutorial
It's like setting scrollLeft/scrollTop . To scroll to the very beginning, we can use scrollTo(0,0) . window.scrollTo(0,0).
Read more >
bvaughn/react-virtualized - Gitter
Hello guys thanks for the awesome work, i am using virtualized list with autosizer and window scroller, the only issue i am facing...
Read more >
javascript - How to check if element is visible after scrolling? - Stack ...
scrollTop (); var pageBottom = pageTop + $(window).height(); var elementTop ... < 0) return false // Check its within the document viewport if...
Read more >
Rendering large lists with React Virtualized - LogRocket Blog
First, you'll see the problems with rendering a huge data set. ... If you resize the window, the list height should adjust automatically: ......
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