Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,23 +160,23 @@ export default class Trigger extends React.Component {
this.clickOutsideHandler = addEventListener(currentDocument,
'mousedown', this.onDocumentClick);
}
// close popup when trigger type is `contextMenu`, or `click` and window is blurred
if (!this.clickBlurOutsideHandler && (this.isClickToHide() || this.isContextMenuToShow())) {
this.clickBlurOutsideHandler = addEventListener(window,
'blur', this.onDocumentClick);
}
// always hide on mobile
if (!this.touchOutsideHandler) {
currentDocument = currentDocument || props.getDocument();
this.touchOutsideHandler = addEventListener(currentDocument,
'touchstart', this.onDocumentClick);
}
// close popup when trigger type contains 'onContextMenu' and document is scrolling.
if (!this.contextMenuOutsideHandler1 && this.isContextMenuToShow()) {
if (!this.contextMenuScrollOutsideHandler && this.isContextMenuToShow()) {
currentDocument = currentDocument || props.getDocument();
this.contextMenuOutsideHandler1 = addEventListener(currentDocument,
this.contextMenuScrollOutsideHandler = addEventListener(currentDocument,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for delay. contextMenuScrollOutsideHandler should get remove after unmounted. And also need a test case for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'scroll', this.onContextMenuClose);
}
// close popup when trigger type contains 'onContextMenu' and window is blur.
if (!this.contextMenuOutsideHandler2 && this.isContextMenuToShow()) {
this.contextMenuOutsideHandler2 = addEventListener(window,
'blur', this.onContextMenuClose);
}
return;
}

Expand Down Expand Up @@ -465,14 +465,14 @@ export default class Trigger extends React.Component {
this.clickOutsideHandler = null;
}

if (this.contextMenuOutsideHandler1) {
this.contextMenuOutsideHandler1.remove();
this.contextMenuOutsideHandler1 = null;
if (this.contextMenuScrollOutsideHandler) {
this.contextMenuScrollOutsideHandler.remove();
this.contextMenuScrollOutsideHandler = null;
}

if (this.contextMenuOutsideHandler2) {
this.contextMenuOutsideHandler2.remove();
this.contextMenuOutsideHandler2 = null;
if (this.clickBlurOutsideHandler) {
this.clickBlurOutsideHandler.remove();
this.clickBlurOutsideHandler = null;
}

if (this.touchOutsideHandler) {
Expand Down