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

This commit is contained in:
kay delaney 2020-08-24 15:38:36 +01:00 committed by GitHub
parent 1778e9f034
commit b54c0b5d52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
}
}