-
-
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 3 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 |
---|---|---|
|
@@ -29,6 +29,8 @@ export default 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 = { | ||
|
@@ -47,6 +49,8 @@ export default class MultiGrid extends React.PureComponent { | |
styleBottomRightGrid: {}, | ||
styleTopLeftGrid: {}, | ||
styleTopRightGrid: {}, | ||
hideTopRightGridScrollbar: false, | ||
hideBottomLeftGridScrollbar: false, | ||
}; | ||
|
||
constructor(props, context) { | ||
|
@@ -82,6 +86,8 @@ export default class MultiGrid extends React.PureComponent { | |
this._rowHeightBottomGrid = this._rowHeightBottomGrid.bind(this); | ||
this._topLeftGridRef = this._topLeftGridRef.bind(this); | ||
this._topRightGridRef = this._topRightGridRef.bind(this); | ||
this._renderBottomLeftGrid = this._renderBottomLeftGrid.bind(this); | ||
this._renderTopRightGrid = this._renderTopRightGrid.bind(this); | ||
} | ||
|
||
forceUpdateGrids() { | ||
|
@@ -623,33 +629,52 @@ export default class MultiGrid extends React.PureComponent { | |
fixedRowCount, | ||
rowCount, | ||
scrollTop, | ||
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, | ||
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.
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 think state structure change in Grid but not in MutliGrid so it is working fine. So we are good here? |
||
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} | ||
scrollTop={scrollTop} | ||
style={this._bottomLeftGridStyle} | ||
tabIndex={null} | ||
width={this._getLeftGridWidth(props)} | ||
width={gridWidth} | ||
/> | ||
); | ||
|
||
if (hideBottomLeftGridScrollbar) { | ||
return ( | ||
<div | ||
style={{ | ||
...this._bottomLeftGridStyle, | ||
height, | ||
width, | ||
}}> | ||
{bottomLeftGrid} | ||
</div> | ||
); | ||
} | ||
return bottomLeftGrid; | ||
} | ||
|
||
_renderBottomRightGrid(props) { | ||
|
@@ -713,16 +738,32 @@ export default class MultiGrid extends React.PureComponent { | |
fixedColumnCount, | ||
fixedRowCount, | ||
scrollLeft, | ||
hideTopRightGridScrollbar, | ||
} = props; | ||
const {showHorizontalScrollbar} = this.state; | ||
|
||
if (!fixedRowCount) { | ||
return null; | ||
} | ||
|
||
const additionalColumnCount = showHorizontalScrollbar ? 1 : 0; | ||
const additionalColumnCount = showHorizontalScrollbar ? 1 : 0, | ||
height = this._getTopGridHeight(props), | ||
width = this._getRightGridWidth(props), | ||
scrollbarSize = this.state.showHorizontalScrollbar ? this.state.scrollbarSize : 0; | ||
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. nit: |
||
|
||
return ( | ||
let gridHeight = height, | ||
style = this._topRightGridStyle; | ||
|
||
if (hideTopRightGridScrollbar) { | ||
gridHeight = height + scrollbarSize; | ||
style = { | ||
...this._topRightGridStyle, | ||
position: 'relative', | ||
left: 0, | ||
}; | ||
} | ||
|
||
const topRightGrid = ( | ||
<Grid | ||
{...props} | ||
cellRenderer={this._cellRendererTopRightGrid} | ||
|
@@ -732,16 +773,31 @@ export default 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 | ||
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.