Skip to content

Commit

Permalink
feat(popover): accept popperOptions (uber#1420)
Browse files Browse the repository at this point in the history
  • Loading branch information
jh3y authored and gergelyke committed Jun 19, 2019
1 parent 9747ba8 commit 5b53b3f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/popover/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,11 @@ class Popover extends React.Component<PopoverPropsT, PopoverPrivateStateT> {

render() {
const rendered = [this.renderAnchor()];

const defaultPopperOptions = {
modifiers: {
preventOverflow: {enabled: !this.props.ignoreBoundary},
},
};
// Only render popover on the browser (portals aren't supported server-side)
if (__BROWSER__) {
if (this.state.isMounted && this.props.isOpen) {
Expand All @@ -450,9 +454,8 @@ class Popover extends React.Component<PopoverPropsT, PopoverPrivateStateT> {
// Remove the `ignoreBoundary` prop in the next major version
// and have it replaced with the TetherBehavior props overrides
popperOptions={{
modifiers: {
preventOverflow: {enabled: !this.props.ignoreBoundary},
},
...defaultPopperOptions,
...this.props.popperOptions,
}}
onPopperUpdate={this.onPopperUpdate}
placement={this.state.placement}
Expand Down
4 changes: 4 additions & 0 deletions src/popover/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ export type BasePopoverPropsT = {
mountNode?: HTMLElement,
/** How long should be fade out animation in ms, default 0ms */
animateOutTime?: number,
/** Popper options override
* https://popper.js.org/popper-documentation.html#Popper.Defaults */
// eslint-disable-next-line flowtype/no-weak-types
popperOptions?: any,
};

// Props for stateless render logic
Expand Down

0 comments on commit 5b53b3f

Please sign in to comment.