Skip to content

Commit

Permalink
do not call setState if combo box is no longer mounted (#807)
Browse files Browse the repository at this point in the history
* do not call setState if combo box is no longer mounted

* call cancel function

* use isMounted var instead of tracking with hasUnmounted
  • Loading branch information
nreese authored May 9, 2018
1 parent 1dfbe02 commit 895f2ca
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/combo_box/combo_box.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export class EuiComboBox extends Component {
};

updateListPosition = (listBounds = this.listBounds) => {
if (!this._isMounted) {
return;
}

if (!this.state.isListOpen) {
return;
}
Expand Down Expand Up @@ -446,6 +450,8 @@ export class EuiComboBox extends Component {
};

componentDidMount() {
this._isMounted = true;

// TODO: This will need to be called once the actual stylesheet loads.
setTimeout(() => {
this.autoSizeInput.copyInputStyles();
Expand Down Expand Up @@ -483,6 +489,8 @@ export class EuiComboBox extends Component {
}

componentWillUnmount() {
this.incrementActiveOptionIndex.cancel();
this._isMounted = false;
document.removeEventListener('click', this.onDocumentFocusChange);
document.removeEventListener('focusin', this.onDocumentFocusChange);
}
Expand Down

0 comments on commit 895f2ca

Please sign in to comment.