From b54c0b5d52e79ba67d72444c80a5dd713099d1d1 Mon Sep 17 00:00:00 2001 From: kay delaney <45561153+kaydelaney@users.noreply.github.com> Date: Mon, 24 Aug 2020 15:38:36 +0100 Subject: [PATCH] UI/ClickOutsideWrapper: Fix for undesirable timepicker behavior (#27164) --- .../ClickOutsideWrapper/ClickOutsideWrapper.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx b/packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx index 5b4e8ca0cb4..a57535037f2 100644 --- a/packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx +++ b/packages/grafana-ui/src/components/ClickOutsideWrapper/ClickOutsideWrapper.tsx @@ -25,17 +25,16 @@ export class ClickOutsideWrapper extends PureComponent { }; 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); } }