Dashboard: Panel menu no longer lingers (#26974)

Closes #26306
This commit is contained in:
kay delaney
2020-08-17 22:54:48 +01:00
committed by GitHub
parent 5da3276db1
commit 19930ee301

View File

@@ -25,17 +25,17 @@ export class ClickOutsideWrapper extends PureComponent<Props, State> {
};
componentDidMount() {
window.addEventListener('click', this.onOutsideClick, false);
document.addEventListener('click', this.onOutsideClick, false);
if (this.props.includeButtonPress) {
// Use keyup since keydown already has an eventlistener on window
window.addEventListener('keyup', this.onOutsideClick, false);
document.addEventListener('keyup', this.onOutsideClick, false);
}
}
componentWillUnmount() {
window.removeEventListener('click', this.onOutsideClick, false);
document.removeEventListener('click', this.onOutsideClick, false);
if (this.props.includeButtonPress) {
window.removeEventListener('keyup', this.onOutsideClick, false);
document.removeEventListener('keyup', this.onOutsideClick, false);
}
}