Skip to content

Commit

Permalink
Fix console warnings with collapsible and autoScroll (dnnsoftware#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikebigun authored and valadas committed Jan 16, 2019
1 parent 269f4ff commit 3cb3a34
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions src/Collapsible/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const page = /Firefox/.test(navigator.userAgent) ?
export default class Collapsible extends Component {
constructor(props) {
super(props);
this.collapsibleRef = React.createRef();
}

componentWillUnmount() {
Expand All @@ -21,14 +20,15 @@ export default class Collapsible extends Component {
this.scrollTimeout = null;
}
}
scroll(height, width) {
scroll(size) {
const {height} = size;
const {scrollDelay} = this.props;
const delay = scrollDelay || scrollDelay === 0 ? scrollDelay : defaultDelay;
if (!this.props.isOpened || !this.props.autoScroll ) {
return;
}
this.scrollTimeout = setTimeout(()=> {
const collapsible = this.collapsibleRef.current;
const collapsible = this.collapsibleRef;
const collapsibleTop = collapsible.getBoundingClientRect().top;
const collapsibleHeight = this.props.fixedHeight || height;
const bodyTop = document.body.getBoundingClientRect().top;
Expand All @@ -50,15 +50,16 @@ export default class Collapsible extends Component {
const {isOpened, style, fixedHeight} = this.props;
const className = this.props.className || "";
return (
<ReactCollapse
isOpened={isOpened}
style={style}
ref={this.collapsibleRef}
className={className}
onMeasure={this.scroll.bind(this)}
fixedHeight={fixedHeight}>
{this.props.children}
</ReactCollapse>
<div ref={(node) => this.collapsibleRef = node} style={{height: "100%", width:"100%"}}>
<ReactCollapse
isOpened={isOpened}
style={style}
className={className}
onMeasure={this.scroll.bind(this)}
fixedHeight={fixedHeight}>
{this.props.children}
</ReactCollapse>
</div>
);
}
}
Expand Down

0 comments on commit 3cb3a34

Please sign in to comment.