-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add options to hide MultiGrid top-right and bottom-left grid scrollbars but still make the scroll events work on those grids #1040
Changes from all commits
d80e8bd
42a3439
e8712fb
55b782c
83f9e12
b259990
c31361d
036b508
53bce7e
7cf66ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,8 @@ class MultiGrid extends React.PureComponent { | |
styleBottomRightGrid: PropTypes.object.isRequired, | ||
styleTopLeftGrid: PropTypes.object.isRequired, | ||
styleTopRightGrid: PropTypes.object.isRequired, | ||
hideTopRightGridScrollbar: PropTypes.bool, | ||
hideBottomLeftGridScrollbar: PropTypes.bool, | ||
}; | ||
|
||
static defaultProps = { | ||
|
@@ -48,6 +50,8 @@ class MultiGrid extends React.PureComponent { | |
styleBottomRightGrid: {}, | ||
styleTopLeftGrid: {}, | ||
styleTopRightGrid: {}, | ||
hideTopRightGridScrollbar: false, | ||
hideBottomLeftGridScrollbar: false, | ||
}; | ||
|
||
state = { | ||
|
@@ -611,32 +615,55 @@ class MultiGrid extends React.PureComponent { | |
fixedColumnCount, | ||
fixedRowCount, | ||
rowCount, | ||
hideBottomLeftGridScrollbar, | ||
} = props; | ||
const {showVerticalScrollbar} = this.state; | ||
|
||
if (!fixedColumnCount) { | ||
return null; | ||
} | ||
|
||
const additionalRowCount = showVerticalScrollbar ? 1 : 0; | ||
const additionalRowCount = showVerticalScrollbar ? 1 : 0, | ||
height = this._getBottomGridHeight(props), | ||
width = this._getLeftGridWidth(props), | ||
scrollbarSize = this.state.showVerticalScrollbar | ||
? this.state.scrollbarSize | ||
: 0, | ||
gridWidth = hideBottomLeftGridScrollbar ? width + scrollbarSize : width; | ||
|
||
return ( | ||
const bottomLeftGrid = ( | ||
<Grid | ||
{...props} | ||
cellRenderer={this._cellRendererBottomLeftGrid} | ||
className={this.props.classNameBottomLeftGrid} | ||
columnCount={fixedColumnCount} | ||
deferredMeasurementCache={this._deferredMeasurementCacheBottomLeftGrid} | ||
height={this._getBottomGridHeight(props)} | ||
height={height} | ||
onScroll={enableFixedColumnScroll ? this._onScrollTop : undefined} | ||
ref={this._bottomLeftGridRef} | ||
rowCount={Math.max(0, rowCount - fixedRowCount) + additionalRowCount} | ||
rowHeight={this._rowHeightBottomGrid} | ||
style={this._bottomLeftGridStyle} | ||
tabIndex={null} | ||
width={this._getLeftGridWidth(props)} | ||
width={gridWidth} | ||
/> | ||
); | ||
|
||
if (hideBottomLeftGridScrollbar) { | ||
return ( | ||
<div | ||
className="BottomLeftGrid_ScrollWrapper" | ||
style={{ | ||
...this._bottomLeftGridStyle, | ||
height, | ||
width, | ||
overflowY: 'hidden', | ||
}}> | ||
{bottomLeftGrid} | ||
</div> | ||
); | ||
} | ||
return bottomLeftGrid; | ||
} | ||
|
||
_renderBottomRightGrid(props) { | ||
|
@@ -700,16 +727,31 @@ class MultiGrid extends React.PureComponent { | |
fixedColumnCount, | ||
fixedRowCount, | ||
scrollLeft, | ||
hideTopRightGridScrollbar, | ||
} = props; | ||
const {showHorizontalScrollbar} = this.state; | ||
const {showHorizontalScrollbar, scrollbarSize} = this.state; | ||
|
||
if (!fixedRowCount) { | ||
return null; | ||
} | ||
|
||
const additionalColumnCount = showHorizontalScrollbar ? 1 : 0; | ||
const additionalColumnCount = showHorizontalScrollbar ? 1 : 0, | ||
height = this._getTopGridHeight(props), | ||
width = this._getRightGridWidth(props), | ||
additionalHeight = showHorizontalScrollbar ? scrollbarSize : 0; | ||
|
||
return ( | ||
let gridHeight = height, | ||
style = this._topRightGridStyle; | ||
|
||
if (hideTopRightGridScrollbar) { | ||
gridHeight = height + additionalHeight; | ||
style = { | ||
...this._topRightGridStyle, | ||
left: 0, | ||
}; | ||
} | ||
|
||
const topRightGrid = ( | ||
<Grid | ||
{...props} | ||
cellRenderer={this._cellRendererTopRightGrid} | ||
|
@@ -719,16 +761,32 @@ class MultiGrid extends React.PureComponent { | |
} | ||
columnWidth={this._columnWidthRightGrid} | ||
deferredMeasurementCache={this._deferredMeasurementCacheTopRightGrid} | ||
height={this._getTopGridHeight(props)} | ||
height={gridHeight} | ||
onScroll={enableFixedRowScroll ? this._onScrollLeft : undefined} | ||
ref={this._topRightGridRef} | ||
rowCount={fixedRowCount} | ||
scrollLeft={scrollLeft} | ||
style={this._topRightGridStyle} | ||
style={style} | ||
tabIndex={null} | ||
width={this._getRightGridWidth(props)} | ||
width={width} | ||
/> | ||
); | ||
|
||
if (hideTopRightGridScrollbar) { | ||
return ( | ||
<div | ||
className="TopRightGrid_ScrollWrapper" | ||
style={{ | ||
...this._topRightGridStyle, | ||
height, | ||
width, | ||
overflowX: 'hidden', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need to wrap it in another div If you need to. you can just modify this._topRightGridStyle = {
...this._topRightGridStyle,
height,
width,
overflowX: 'hidden'
} Unless Im misunderstanding something :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. We need this extra wrapper so we can hide the scrollbar with a hack. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wuweiweiwu , are you waiting for some change here? |
||
}}> | ||
{topRightGrid} | ||
</div> | ||
); | ||
} | ||
return topRightGrid; | ||
} | ||
|
||
_rowHeightBottomGrid = ({index}) => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I don't think there is a need to specify defaultProps for these. Since it would be
undefined
if not passed in. Which is a falsey valueThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added because there was an existing pattern for
enableFixedColumnScroll
andenableFixedRowScroll
. So followed it.