Skip to content

Commit

Permalink
fix EuiSuperSelect from accessing ref when unmounted (#1369)
Browse files Browse the repository at this point in the history
* fix EuiSuperSelect from accessing ref when unmounted

* change log
  • Loading branch information
nreese authored Dec 13, 2018
1 parent caa0827 commit 949839d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Added `anchorClassName` prop to `EuiPopover` ([#1367](https://github.com/elastic/eui/pull/1367))
- Added support for `fullWidth` on `EuiSuperSelect` ([#1367](https://github.com/elastic/eui/pull/1367))
- Applied new scrollbar customization for Firefox ([#1367](https://github.com/elastic/eui/pull/1367))
- Fixed `EuiSuperSelect` from accessing ref when unmounted ([1369](https://github.com/elastic/eui/pull/1369))

## [`5.7.0`](https://github.com/elastic/eui/tree/v5.7.0)

Expand Down
11 changes: 11 additions & 0 deletions src/components/form/super_select/super_select.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ export class EuiSuperSelect extends Component {
};
}

componentDidMount() {
this._isMounted = true;
}

componentWillUnmount() {
this._isMounted = false;
}

setItemNode = (node, index) => {
this.itemNodes[index] = node;
};
Expand All @@ -48,6 +56,9 @@ export class EuiSuperSelect extends Component {
);

requestAnimationFrame(() => {
if (!this._isMounted) {
return;
}
this.setState({
menuWidth: this.popoverRef.getBoundingClientRect().width - 2, // account for border not inner shadow
});
Expand Down

0 comments on commit 949839d

Please sign in to comment.