Skip to content

Commit

Permalink
fix(react): prevent default when handling react tooltip mouse events (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
cx0der authored and abbeyhrt committed Oct 28, 2019
1 parent 0389110 commit 1884308
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/react/src/components/Tooltip/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 1884308

Please sign in to comment.