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.

Horizontal overflow on VariableSizeGrid

See original GitHub issue

Similar to https://github.com/bvaughn/react-window/issues/22. Except this time it’s for VariableSizeGrid. I’ve created a few examples to demonstrate.

Horizontal scrollbar appears on OSes with always visible scrollbars (e.g. Windows) once scrolled a bit: https://codesandbox.io/s/r55m5n027n

The same issue could be reproduced on other OSes (e.g. macOS) when using custom scrollbars via :-webkit-scrollbar: https://codesandbox.io/s/618026v83r

The only workaround I’ve found is to offset each column by scrollbar width: https://codesandbox.io/s/l2rqwyv989

Ofc then we have to know the scrollbar width beforehand either using a constant width when we have custom scrollbars or using some kind of width detection mechanism (calculating from elm.clientWidth - elm.offsetWidth). The latter sounds more ugly and could lead to jank when called to frequently. But then again, we would only need to calculate scrollbar width once in user’s session.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bvaughncommented, Oct 3, 2018

I don’t think this is the same as #22. I think grid is kind of behaving correctly in this case by adding the horizontal scroll bar. (Although I agree it’s weird that it only appears once you start to scroll. At least for me though, the Code Sandbox page you linked to itself also does the same thing with a horizontal scrollbar. I think this is kind of just a janky browser quirk.)

The same issue could be reproduced on other OSes (e.g. macOS) when using custom scrollbars via :-webkit-scrollbar:

Fair enough, although I’m not really interested in supporting custom scrollbars with this lib.

The only workaround I’ve found is to offset each column by scrollbar width:

If you definitely don’t want to have horizontal scrollbars, you could add style={{ overflowX: 'hidden' }} to the grid in question. But as I said, I think in this case it’s behavior correctly.

If you really want a non-horizontally scrolling grid, then it sounds like you actually want a list.

I’m going to close this issue because I think it reflects a misunderstanding but we can continue to talk on it if anything I’ve said in response seems incorrect! 😄

0reactions
bvaughncommented, Oct 3, 2018

I have variable column count with fixed width

In this case, it sounds like VariableSizeGrid is the right choice for you then 👍but if your grid ends up having two columns, and each is 300 pixels wide, and your grid ends up being 600 pixels wide– then I believe the correct thing for VariableSizeGrid to do is to show both a vertical and horizontal scroll bar (as the Code Sandbox you linked to shows) 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

The horizontal overflow problem
My good friend, Wei, has a pet peeve: unintended horizontal over-scrolling on mobile. Which is very different from intentional horizontal ...
Read more >
Virtualize large lists with react-window - web.dev
List virtualization, or "windowing", is the concept of only rendering what is visible to the user. The number of elements that are rendered...
Read more >
Scrollable Grid with Just-in-Time Data Loading – Using React ...
Grid allows you to window both vertically and horizontally, ... do you know how can I fetch data in VariableSizeGrid on horizontal scroll....
Read more >
react-window
Examples. Fixed Size List; Variable Size List; Fixed Size Grid; Variable Size Grid; Scrolling indicators; Scrolling to an item; Memoized List items ...
Read more >
How to virtualize large lists using react-window
When we scroll down the page to the areas that the browser skipped ... in both directions: vertically (columns) and horizontally (rows).
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