Skip to content

Commit b24871f

Browse files
committed
Merge pull request bvaughn#132 from bvaughn/issues/116
Fixed issue where Grid scrollbars would not disappear once shown
2 parents 763ea80 + dd6f617 commit b24871f

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

source/Grid/Grid.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -452,26 +452,38 @@ export default class Grid extends Component {
452452
}
453453
}
454454

455+
const gridStyle = {
456+
height: height,
457+
width: width
458+
}
459+
460+
const totalColumnsWidth = this._getTotalColumnsWidth()
461+
const totalRowsHeight = this._getTotalRowsHeight()
462+
463+
// Force browser to hide scrollbars when we know they aren't necessary.
464+
// Otherwise once scrollbars appear they may not disappear again.
465+
// For more info see issue #116
466+
if (totalColumnsWidth <= width && totalRowsHeight <= height) {
467+
gridStyle.overflow = 'hidden'
468+
}
469+
455470
return (
456471
<div
457472
ref='scrollingContainer'
458473
className={cn('Grid', className)}
459474
onKeyDown={this._onKeyPress}
460475
onScroll={this._onScroll}
461476
tabIndex={0}
462-
style={{
463-
height: height,
464-
width: width
465-
}}
477+
style={gridStyle}
466478
>
467479
{childrenToDisplay.length > 0 &&
468480
<div
469481
className='Grid__innerScrollContainer'
470482
style={{
471-
width: this._getTotalColumnsWidth(),
472-
height: this._getTotalRowsHeight(),
473-
maxWidth: this._getTotalColumnsWidth(),
474-
maxHeight: this._getTotalRowsHeight(),
483+
width: totalColumnsWidth,
484+
height: totalRowsHeight,
485+
maxWidth: totalColumnsWidth,
486+
maxHeight: totalRowsHeight,
475487
pointerEvents: isScrolling ? 'none' : 'auto'
476488
}}
477489
>

0 commit comments

Comments
 (0)