Skip to content

Commit

Permalink
fix(events): add useCapture to events attached to document (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSharpieOne authored and eddywashere committed Oct 25, 2016
1 parent f23a323 commit 18d7d04
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ class Dropdown extends React.Component {
}

addEvents() {
document.addEventListener('click', this.handleDocumentClick);
document.addEventListener('click', this.handleDocumentClick, true);
}

removeEvents() {
document.removeEventListener('click', this.handleDocumentClick);
document.removeEventListener('click', this.handleDocumentClick, true);
}

handleDocumentClick(e) {
Expand Down
4 changes: 2 additions & 2 deletions src/TetherContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class TetherContent extends React.Component {
}

hide() {
document.removeEventListener('click', this.handleDocumentClick);
document.removeEventListener('click', this.handleDocumentClick, true);

if (this._element) {
document.body.removeChild(this._element);
Expand All @@ -96,7 +96,7 @@ class TetherContent extends React.Component {
}

show() {
document.addEventListener('click', this.handleDocumentClick);
document.addEventListener('click', this.handleDocumentClick, true);

this._element = document.createElement('div');
document.body.appendChild(this._element);
Expand Down
12 changes: 6 additions & 6 deletions src/Tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ class Tooltip extends React.Component {
}

addTargetEvents() {
this._target.addEventListener('mouseover', this.onMouseOverTooltip);
this._target.addEventListener('mouseout', this.onMouseLeaveTooltip);
document.addEventListener('click', this.handleDocumentClick);
this._target.addEventListener('mouseover', this.onMouseOverTooltip, true);
this._target.addEventListener('mouseout', this.onMouseLeaveTooltip, true);
document.addEventListener('click', this.handleDocumentClick, true);
}

removeTargetEvents() {
this._target.removeEventListener('mouseover', this.onMouseOverTooltip);
this._target.removeEventListener('mouseout', this.onMouseLeaveTooltip);
document.removeEventListener('click', this.handleDocumentClick);
this._target.removeEventListener('mouseover', this.onMouseOverTooltip, true);
this._target.removeEventListener('mouseout', this.onMouseLeaveTooltip, true);
document.removeEventListener('click', this.handleDocumentClick, true);
}

toggle(e) {
Expand Down

0 comments on commit 18d7d04

Please sign in to comment.