fix: Table Autosizing Has Unnecessary Horizontal Scroll Bars #19628
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.
SUMMARY
On Table Charts, the auto-sizing in table charts forces a scroll bar in and expands the cells even when there is space available.
This implements a scroll bar and takes away additional space that isn't needed. For example - a table chart with 6 columns and enough empty space will still implement a scroll.
The issue why this is happening is that, when calculating the columns width, we're using the
clientWidth
, which rounds the number. So, the total width of the table could be 1000, but due to rounding, the sum of the columns could yield 1001 and thus causing the scrollbar to appear.This PR switches the width calculation to
getBoundingClientRect
, which does gives the result without rounding (we're still defaulting to clientWidth, just in case).BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before:
Screen.Recording.2022-04-08.at.17.20.36.mov
After:
new.mov
TESTING INSTRUCTIONS
The chart, if no width is specified to any of it's column, should take the width of the panel and don't show the horizontal scrollbar
ADDITIONAL INFORMATION