Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Issue 216 - Scrollbar alignment #247

Merged
merged 4 commits into from
Nov 21, 2018

Conversation

Marc-Andre-Rivet
Copy link
Contributor

@Marc-Andre-Rivet Marc-Andre-Rivet commented Nov 20, 2018

Fixes #216, #203.

After a pretty big false start, using a "phantom" div we can calculate the width of the vertical scrollbar and apply that width as an extra margin for the fixed rows section.. allowing scrolling to stay aligned throughout.

With disappearing scrollbars:
image

With always visible scrollbars:
image

@chriddyp chriddyp temporarily deployed to dash-table-review-pr-247 November 20, 2018 02:40 Inactive
"@storybook/cli": "^4.0.2",
"@storybook/react": "^4.0.2",
"@storybook/cli": "^4.0.7",
"@storybook/react": "^4.0.7",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having issues running storybook locally, updating fixes the issue -- local dep of react needs to be updated

resolve(width);
}, 0);
});
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create a phantom div with a child to calculate the width of the scrollbar -- if the scrollbar disappears, it will have 0 width

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Promise polyfill for IE11 is managed automatically by Babel)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - I had a few questions about if this shouldn't just be a React component - had a small discussion with @Marc-Andre-Rivet and came to the conclusion that because this is just a calculation, it doesn't necessarily need to be a React component.

@@ -144,6 +147,8 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,

this.updateStylesheet();

getScrollbarWidth().then((scrollbarWidth: number) => this.setState({ scrollbarWidth }));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-evaluate scrollbar width on resize (to cover zoom case) and update state

const fragmentStyles: (CSSProperties | undefined)[][] = [
[
undefined,
{ marginRight: this.state.scrollbarWidth }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a margin to the fixed rows

@vedulaabhi
Copy link

Hi,

This Abhishek from Invesco. Just wanted to know if this issue is fixed and if not is there any workaround from styling perspective included in our code.

@Marc-Andre-Rivet
Copy link
Contributor Author

@vedulaabhi This PR should fix the issue in all known scenarios on all Mac and Windows browsers supported by the table. No additional workaround is necessary to make the fix work.

@vedulaabhi
Copy link

@Marc-Andre-Rivet will you be including this in the next release and if so can you pls let me know when we can expect the release as this is really important for our ispace app.

@Marc-Andre-Rivet
Copy link
Contributor Author

@vedulaabhi Once the review goes through this will be released as 3.1.7 -- this is the next release :)

Copy link
Contributor

@valentijnnieman valentijnnieman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small nitpick, other than that it LGTM.

@@ -646,7 +662,8 @@ export default class ControlledTable extends PureComponent<ControlledTableProps,
onScroll={this.onScroll}
>{row.map((cell, columnIndex) => (<div
key={columnIndex}
ref={`r${rowIndex}c${columnIndex}`}
ref={`r${rowIndex}c${columnIndex}`}
style={fragmentStyles[rowIndex][columnIndex]}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpick about indentation here. 🐱

resolve(width);
}, 0);
});
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - I had a few questions about if this shouldn't just be a React component - had a small discussion with @Marc-Andre-Rivet and came to the conclusion that because this is just a calculation, it doesn't necessarily need to be a React component.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Side scroll misalignment
4 participants