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

Issue 801 - Flickering scrollbar #809

Merged
merged 4 commits into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).

### Fixed
- [#806](https://github.com/plotly/dash-table/pull/806) Fix a bug where fixed rows a misaligned after navigating or editing cells [#803](https://github.com/plotly/dash-table/issues/803)
- [#809](https://github.com/plotly/dash-table/pull/809) Fix a bug where a scrollbar flickers on table render [#801](https://github.com/plotly/dash-table/issues/801)

## [4.8.1] - 2020-06-19
### Fixed
Expand Down
6 changes: 3 additions & 3 deletions src/core/browser/scrollbarWidth.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default (): Promise<number> => {
export default (target: HTMLElement): Promise<number> => {
const parent = document.createElement('div');
parent.style.position = 'absolute';
parent.style.visibility = 'hidden';
Expand All @@ -11,13 +11,13 @@ export default (): Promise<number> => {
child.style.height = '100px';

parent.appendChild(child);
document.body.appendChild(parent);
target.appendChild(parent);

return new Promise<number>(resolve => {
setTimeout(() => {
const width = child.clientWidth - parent.clientWidth;

document.body.removeChild(parent);
target.removeChild(parent);
resolve(width);
}, 0);
});
Expand Down
9 changes: 4 additions & 5 deletions src/dash-table/components/ControlledTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ export default class ControlledTable extends PureComponent<ControlledTableProps>

forceHandleResize = () => this.handleResize();

getScrollbarWidthOnce = R.once(getScrollbarWidth);

handleResizeIf = memoizeOne((..._: any[]) => {
const { r0c0, r0c1, r1c0, r1c1 } = this.refs as Refs;

Expand Down Expand Up @@ -339,15 +341,13 @@ export default class ControlledTable extends PureComponent<ControlledTableProps>
setState
} = this.props;

const { r1c1 } = this.refs as Refs;
const { r1, r1c1 } = this.refs as Refs;

if (!this.isDisplayed(r1c1)) {
return;
}

this.updateStylesheet();

getScrollbarWidth().then((scrollbarWidth: number) => setState({ scrollbarWidth }));
this.getScrollbarWidthOnce(r1).then((scrollbarWidth: number) => setState({ scrollbarWidth }));

const { r0c0, r0c1, r1c0 } = this.refs as Refs;

Expand Down Expand Up @@ -395,7 +395,6 @@ export default class ControlledTable extends PureComponent<ControlledTableProps>
const firstTdBounds = firstVisibleTd.getBoundingClientRect();

const width = firstTdBounds.left - r1c1FragmentBounds.left;
const { r1 } = this.refs as Refs;

r0c1.style.marginLeft = `-${width + r1.scrollLeft}px`;
r1c1.style.marginLeft = `-${width}px`;
Expand Down