From 1884308c405a4e96b15cd090a91eedb027003f4a Mon Sep 17 00:00:00 2001 From: Shivakumar Thanikachalam <277487+cx0der@users.noreply.github.com> Date: Wed, 9 Oct 2019 05:01:26 +0530 Subject: [PATCH] fix(react): prevent default when handling react tooltip mouse events (#4196) * fix(react): prevent default when handling react tooltip mouse events When handling mouse events invoke evt.preventDefault to stop the default handler from firing when Tooltip is used inside a form element which has an id. * fix(react): prevent default when handling react tooltip keyboard events When handling keydown events invoke event.preventDefault to stop the default handler from firing when Tooltip is used inside a form element which has an id. --- packages/react/src/components/Tooltip/Tooltip.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react/src/components/Tooltip/Tooltip.js b/packages/react/src/components/Tooltip/Tooltip.js index 5da2568febbf..5a22adb2e107 100644 --- a/packages/react/src/components/Tooltip/Tooltip.js +++ b/packages/react/src/components/Tooltip/Tooltip.js @@ -303,6 +303,7 @@ class Tooltip extends Component { this._hasContextMenu = evt.type === 'contextmenu'; if (state === 'click') { evt.stopPropagation(); + evt.preventDefault(); const shouldOpen = this.isControlled ? !this.props.open : !this.state.open; @@ -338,6 +339,7 @@ class Tooltip extends Component { if (keyDownMatch(event, [keys.Enter, keys.Space])) { event.stopPropagation(); + event.preventDefault(); const shouldOpen = this.isControlled ? !this.props.open : !this.state.open;