Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Karl Taylor authored and Karl Taylor committed Feb 25, 2019
2 parents 5f848bb + 6217f06 commit cce5b4b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/Collapsible.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class Collapsible extends Component {
constructor(props) {
super(props)

this.timeout = undefined;

// Bind class methods
this.handleTriggerClick = this.handleTriggerClick.bind(this);
this.handleTransitionEnd = this.handleTransitionEnd.bind(this);
Expand Down Expand Up @@ -41,7 +43,8 @@ class Collapsible extends Component {
}

if (prevState.height === 'auto' && this.state.shouldSwitchAutoOnNextCycle === true) {
window.setTimeout(() => { // Set small timeout to ensure a true re-render
window.clearTimeout(this.timeout);
this.timeout = window.setTimeout(() => { // Set small timeout to ensure a true re-render
this.setState({
height: 0,
overflow: 'hidden',
Expand All @@ -62,6 +65,10 @@ class Collapsible extends Component {
}
}
}

componentWillUnmount () {
window.clearTimeout(this.timeout);
}

closeCollapsible() {
this.setState({
Expand Down Expand Up @@ -92,11 +99,12 @@ class Collapsible extends Component {
}

handleTriggerClick(event) {
event.preventDefault();

if (this.props.triggerDisabled) {
return
}

event.preventDefault();


if (this.props.handleTriggerClick) {
this.props.handleTriggerClick(this.props.accordionPosition);
Expand Down Expand Up @@ -139,7 +147,7 @@ class Collapsible extends Component {
}

render() {
var dropdownStyle = {
const dropdownStyle = {
height: this.state.height,
WebkitTransition: this.state.transition,
msTransition: this.state.transition,
Expand Down

0 comments on commit cce5b4b

Please sign in to comment.