Skip to content

Commit

Permalink
fix EuiToolTip from setting state on unmounted component (#1163)
Browse files Browse the repository at this point in the history
* fix EuiToolTip from setting state on unmounted component

* changelog

* move check to hideToolTip method
  • Loading branch information
nreese authored Sep 5, 2018
1 parent 54e8397 commit 95de5a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Fixed `EuiTooltip` to interact correctly when the anchor is a disabled form element ([#1158](https://github.com/elastic/eui/pull/1158))
- Fixed `EuiButton` (with icon) and `EuiButtonEmpty` truncation ([#1145](https://github.com/elastic/eui/pull/1145))
- Fixed alignment and coloring of form control clear button ([#1145](https://github.com/elastic/eui/pull/1145))
- Fixed `EuiToolTip` from setting state after component unmounts ([#1163](https://github.com/elastic/eui/pull/1163))

## [`3.8.0`](https://github.com/elastic/eui/tree/v3.8.0)

Expand Down
12 changes: 11 additions & 1 deletion src/components/tool_tip/tool_tip.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ export class EuiToolTip extends Component {
};
}

componentDidMount() {
this._isMounted = true;
}

componentWillUnmount() {
this._isMounted = false;
}

componentDidUpdate(prevProps, prevState) {
if (prevState.visible === false && this.state.visible === true) {
requestAnimationFrame(this.testAnchor);
Expand Down Expand Up @@ -113,7 +121,9 @@ export class EuiToolTip extends Component {
};

hideToolTip = () => {
this.setState({ visible: false });
if (this._isMounted) {
this.setState({ visible: false });
}
};

onFocus = () => {
Expand Down

0 comments on commit 95de5a7

Please sign in to comment.