Resize cols to prevent bottom scrollbar when right scrollbar appears #883
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When right scrollbar appears, resize columns a tiny bit to prevent bottom scrollbar from appearing. Only applies when user has "scrollbars always on" enabled in OS settings.
Before
(Edit: gif fixed)
After
Details
This PR has no effect unless scrollbars are set to "always on" in the user's OS settings.
Every time
ensureWidthContraint()
is called, we calculate the width of the right scrollbar by taking the difference between the overflowoffsetWidth
andclientWidth
. If the difference is positive, the right scrollbar has just appeared. If negative, it has vanished.When the scrollbar appears, we compare the total width of the columns with the width of the container. If the columns exceed the container by less than, or exactly, the width of the scrollbar, we conclude that the right scrollbar has just pushed the container into horizontal overflow. In this case, we scale the columns down by one scrollbar width using the table's specified
fillMode
, which prevents the bottom scroll bar from appearing.We take the inverse action when the scrollbar vanishes. This ensures that repeatedly expanding and contracting rows does not result in a net change in column widths.
Tests
Not feasible. The results are dependent on OS-level scrollbar settings.