@@ -2,7 +2,7 @@ import * as React from "react";
2
2
import { css } from "emotion" ;
3
3
import { AutoSizer , MultiGrid , GridCellProps } from "react-virtualized" ;
4
4
5
- import { headerCss , cellCss , tableCss } from "../style" ;
5
+ import { headerCss , cellCss , tableCss , rightGrid } from "../style" ;
6
6
7
7
import { IColumnProps , Column } from "./Column" ;
8
8
import memoizeOne from "memoize-one" ;
@@ -17,11 +17,15 @@ export interface ITableProps {
17
17
| React . ReactElement < IColumnProps > ;
18
18
}
19
19
20
+ export interface ITableState {
21
+ isScroll : boolean ;
22
+ }
23
+
20
24
const ROW_HEIGHT = 35 ;
21
25
22
26
const DEFAULT_WIDTH = 1024 ;
23
27
const DEFAULT_HEIGHT = 768 ;
24
- export class Table < T > extends React . PureComponent < ITableProps , { } > {
28
+ export class Table < T > extends React . PureComponent < ITableProps , ITableState > {
25
29
public multiGridRef : { recomputeGridSize ?: any } = { } ;
26
30
27
31
public getData = memoizeOne (
@@ -57,6 +61,11 @@ export class Table<T> extends React.PureComponent<ITableProps, {}> {
57
61
this . setRef = this . setRef . bind ( this ) ;
58
62
this . updateGridSize = this . updateGridSize . bind ( this ) ;
59
63
this . getGrid = this . getGrid . bind ( this ) ;
64
+ this . onScrollbarPresenceChange = this . onScrollbarPresenceChange . bind ( this ) ;
65
+
66
+ this . state = {
67
+ isScroll : false
68
+ } ;
60
69
}
61
70
62
71
public render ( ) {
@@ -73,7 +82,22 @@ export class Table<T> extends React.PureComponent<ITableProps, {}> {
73
82
) ;
74
83
}
75
84
85
+ private onScrollbarPresenceChange ( { horizontal } ) {
86
+ if ( horizontal ) {
87
+ this . setState ( {
88
+ isScroll : true
89
+ } ) ;
90
+
91
+ return ;
92
+ }
93
+
94
+ this . setState ( {
95
+ isScroll : false
96
+ } ) ;
97
+ }
98
+
76
99
private getGrid ( { width, height } ) {
100
+ const rightGridStyles = this . state . isScroll ? rightGrid : "" ;
77
101
const columnCount = React . Children . count ( this . props . children ) ;
78
102
const columnSizes = this . getColumnSizes (
79
103
React . Children . toArray ( this . props . children ) as Array <
@@ -88,6 +112,7 @@ export class Table<T> extends React.PureComponent<ITableProps, {}> {
88
112
89
113
return (
90
114
< MultiGrid
115
+ onScrollbarPresenceChange = { this . onScrollbarPresenceChange }
91
116
ref = { this . setRef }
92
117
fixedColumnCount = { 1 }
93
118
fixedRowCount = { 1 }
@@ -102,6 +127,8 @@ export class Table<T> extends React.PureComponent<ITableProps, {}> {
102
127
width = { width }
103
128
hideTopRightGridScrollbar = { true }
104
129
hideBottomLeftGridScrollbar = { true }
130
+ classNameTopRightGrid = { rightGridStyles }
131
+ classNameBottomRightGrid = { rightGridStyles }
105
132
/>
106
133
) ;
107
134
}
0 commit comments