Skip to content

Commit

Permalink
Expose onBodyClick to popover (segmentio#586)
Browse files Browse the repository at this point in the history
* Expose onBodyClick to popover

* Fix lint error
  • Loading branch information
dy authored and Matt Shwery committed Jul 8, 2019
1 parent 52be0d0 commit d755b5e
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/popover/src/Popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ export default class Popover extends Component {
* Function that will be called when the exit transition is complete.
*/
onCloseComplete: PropTypes.func.isRequired,

/**
* Function that will be called when the body is clicked.
*/
onBodyClick: PropTypes.func.isRequired,

/**
* When true, bring focus inside of the Popover on open.
Expand All @@ -107,7 +112,8 @@ export default class Popover extends Component {
onOpen: () => {},
onClose: () => {},
onOpenComplete: () => {},
onCloseComplete: () => {},
onCloseComplete: () => {},
onBodyClick: () => {},
bringFocusInside: false,
shouldCloseOnExternalClick: true,
trigger: 'click'
Expand Down Expand Up @@ -196,6 +202,9 @@ export default class Popover extends Component {
if (this.popoverNode && this.popoverNode.contains(e.target)) {
return
}

// Notify body click
this.props.onBodyClick(e)

if (this.props.shouldCloseOnExternalClick === false) {
return
Expand Down

0 comments on commit d755b5e

Please sign in to comment.