UI/ClickOutsideWrapper: Fix for undesirable timepicker behavior (#27164)

pull/27177/head
kay delaney 5 years ago committed by GitHub
parent 1778e9f034
commit b54c0b5d52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx

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

Loading…
Cancel
Save