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

Commit 1fa6817

Browse files
Issue 801 - Flickering scrollbar (#809)
1 parent ee4a469 commit 1fa6817

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1010

1111
### Fixed
1212
- [#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)
13+
- [#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)
1314

1415
## [4.8.1] - 2020-06-19
1516
### Fixed

src/core/browser/scrollbarWidth.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default (): Promise<number> => {
1+
export default (target: HTMLElement): Promise<number> => {
22
const parent = document.createElement('div');
33
parent.style.position = 'absolute';
44
parent.style.visibility = 'hidden';
@@ -11,13 +11,13 @@ export default (): Promise<number> => {
1111
child.style.height = '100px';
1212

1313
parent.appendChild(child);
14-
document.body.appendChild(parent);
14+
target.appendChild(parent);
1515

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

20-
document.body.removeChild(parent);
20+
target.removeChild(parent);
2121
resolve(width);
2222
}, 0);
2323
});

src/dash-table/components/ControlledTable/index.tsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ export default class ControlledTable extends PureComponent<ControlledTableProps>
308308

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

311+
getScrollbarWidthOnce = R.once(getScrollbarWidth);
312+
311313
handleResizeIf = memoizeOne((..._: any[]) => {
312314
const { r0c0, r0c1, r1c0, r1c1 } = this.refs as Refs;
313315

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

342-
const { r1c1 } = this.refs as Refs;
344+
const { r1, r1c1 } = this.refs as Refs;
343345

344346
if (!this.isDisplayed(r1c1)) {
345347
return;
346348
}
347349

348-
this.updateStylesheet();
349-
350-
getScrollbarWidth().then((scrollbarWidth: number) => setState({ scrollbarWidth }));
350+
this.getScrollbarWidthOnce(r1).then((scrollbarWidth: number) => setState({ scrollbarWidth }));
351351

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

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

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

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

0 commit comments

Comments
 (0)