Skip to content

Commit

Permalink
Fix invalid overflow style
Browse files Browse the repository at this point in the history
It seems that after specifying an overflowX (or overflowY) style then subsequent overflow styles get dropped. This causes the broken behavior originally reported in #525. This commit resolves that issue.
  • Loading branch information
Brian Vaughn committed Jan 4, 2017
1 parent 2c92cb0 commit b5b8e29
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions source/Collection/CollectionView.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,6 @@ export default class CollectionView extends Component {
boxSizing: 'border-box',
direction: 'ltr',
height: autoHeight ? 'auto' : height,
overflow: 'auto',
position: 'relative',
WebkitOverflowScrolling: 'touch',
width,
Expand All @@ -367,12 +366,18 @@ export default class CollectionView extends Component {
// For more info see issue #116
const verticalScrollBarSize = totalHeight > height ? this._scrollbarSize : 0
const horizontalScrollBarSize = totalWidth > width ? this._scrollbarSize : 0
if (totalWidth + verticalScrollBarSize <= width) {
collectionStyle.overflowX = 'hidden'
}
if (totalHeight + horizontalScrollBarSize <= height) {
collectionStyle.overflowY = 'hidden'
}

// Also explicitly init styles to 'auto' if scrollbars are required.
// This works around an obscure edge case where external CSS styles have not yet been loaded,
// But an initial scroll index of offset is set as an external prop.
// Without this style, Grid would render the correct range of cells but would NOT update its internal offset.
// This was originally reported via clauderic/react-infinite-calendar/issues/23
collectionStyle.overflowX = totalWidth + verticalScrollBarSize <= width
? 'hidden'
: 'auto'
collectionStyle.overflowY = totalHeight + horizontalScrollBarSize <= height
? 'hidden'
: 'auto'

return (
<div
Expand Down

0 comments on commit b5b8e29

Please sign in to comment.