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

MultiGrid: extra row/column to fit scrollbar must be added if the opposite scrollbar exists

Open jeron-diovis opened this issue 6 years ago • 4 comments

Check out this fiddle, please: https://codesandbox.io/s/0om24qx99w

Under option happy-path is a reduced copy of your official MultiGrid demo. In this example both total rows height and total columns width exceeds height/width of grid, so both scrollbars are visible and extra row/column is added to align content:

screenshot 2018-03-15 14 10 01

Under option width there is a case when total columns width is equal to grid width, and total rows height exceeds grid height. In this case Grid thinks that horizontal scrollbar should not be displayed (accordingly to [1], [2]), and so extra column is not added ([3], [4]).

But vertical scroll exists, and it takes some space inside grid. So in fact grid width becomes a bit less than total columns width, and horizontal scroll still appears – while being not compensated by extra column:

screenshot 2018-03-15 14 10 11

All the same is vice versa for height option:

screenshot 2018-03-15 14 10 22

I managed to patch this problem in my project, but via very bad hack with updating state of a child by it's parent, intruding in child's internal logic.

It looks like Grid logic should be updated, so if one scrollbar is present, second one must be considered present too.

jeron-diovis avatar Mar 15 '18 12:03 jeron-diovis

Same issue here.. :/

mikkelwf avatar Mar 27 '18 07:03 mikkelwf

@bvaughn

1 fixed row with visible scrollbar. is it possible to fix? thx

Screenshot 2019-07-31 at 09 28 14

casvil avatar Jul 31 '19 07:07 casvil

Any improvements on this issue?

akhilaudable avatar Feb 26 '20 08:02 akhilaudable

For anyone facing this issue, a potential solution would be to calculate the scrollbar size with the prop onScrollbarPresenceChange, for instance:

onScrollbarPresenceChange={({vertical, size}) => {
                if (vertical) {
                  setScrollBarWidth(size);
                } else {
                  setScrollBarWidth(0);
                }
              }}

And finally in the columnWidth prop, subtract this value to the columns width! Hope it helps

jesus4497 avatar Oct 24 '22 20:10 jesus4497