-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(Modal|Popup|Portal): fix usage of eventStack sub/unsub #2099
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,9 @@ class Portal extends Component { | |
/** Controls whether or not the portal should open when mousing over the trigger. */ | ||
openOnTriggerMouseEnter: PropTypes.bool, | ||
|
||
/** Event pool namespace that is used to handle component events */ | ||
eventPool: PropTypes.string, | ||
|
||
/** Controls whether the portal should be prepended to the mountNode instead of appended. */ | ||
prepend: PropTypes.bool, | ||
|
||
|
@@ -126,6 +129,7 @@ class Portal extends Component { | |
closeOnDocumentClick: true, | ||
closeOnEscape: true, | ||
openOnTriggerClick: true, | ||
eventPool: 'default', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^ |
||
} | ||
|
||
static autoControlledProps = [ | ||
|
@@ -374,6 +378,7 @@ class Portal extends Component { | |
const { | ||
mountNode = isBrowser ? document.body : null, | ||
prepend, | ||
eventPool, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^ |
||
} = this.props | ||
|
||
this.rootNode = document.createElement('div') | ||
|
@@ -384,8 +389,8 @@ class Portal extends Component { | |
mountNode.appendChild(this.rootNode) | ||
} | ||
|
||
eventStack.sub('click', this.handleDocumentClick, 'Portal') | ||
eventStack.sub('keydown', this.handleEscape, 'Portal') | ||
eventStack.sub('click', this.handleDocumentClick, eventPool) | ||
eventStack.sub('keydown', this.handleEscape, eventPool) | ||
_.invoke(this.props, 'onMount', null, this.props) | ||
} | ||
|
||
|
@@ -394,6 +399,8 @@ class Portal extends Component { | |
|
||
debug('unmountPortal()') | ||
|
||
const { eventPool } = this.props | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New line before this declaration is useless. |
||
|
||
ReactDOM.unmountComponentAtNode(this.rootNode) | ||
this.rootNode.parentNode.removeChild(this.rootNode) | ||
|
||
|
@@ -403,8 +410,8 @@ class Portal extends Component { | |
this.rootNode = null | ||
this.portalNode = null | ||
|
||
eventStack.unsub('click', this.handleDocumentClick, 'Portal') | ||
eventStack.unsub('keydown', this.handleEscape, 'Portal') | ||
eventStack.unsub('click', this.handleDocumentClick, eventPool) | ||
eventStack.unsub('keydown', this.handleEscape, eventPool) | ||
_.invoke(this.props, 'onUnmount', null, this.props) | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add prop in alphabetical order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
didn't know about this, done :)