Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions src/modules/Popup/Popup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ export interface StrictPopupProps extends StrictPortalProps {
/** Invert the colors of the popup */
inverted?: boolean

/** The node where the popup should mount. Defaults to document.body. */
mountNode?: any

/**
* Offset values in px unit to apply to rendered popup. The basic offset accepts an
* array with two numbers in the form [skidding, distance]:
Expand Down
9 changes: 9 additions & 0 deletions src/modules/Popup/Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
customPropTypes,
getElementType,
getUnhandledProps,
isBrowser,
makeDebugger,
SUI,
useKeyOnly,
Expand Down Expand Up @@ -68,6 +69,9 @@ export default class Popup extends Component {
clearTimeout(this.timeoutId)
}

// Do not access document when server side rendering
getMountNode = () => (isBrowser() ? this.props.mountNode || document.body : null)

getPortalProps = () => {
debug('getPortalProps()')
const portalProps = {}
Expand Down Expand Up @@ -231,6 +235,7 @@ export default class Popup extends Component {
trigger,
} = this.props
const { closed, portalRestProps } = this.state
const mountNode = this.getMountNode()

if (closed || disabled) {
return trigger
Expand Down Expand Up @@ -285,6 +290,7 @@ export default class Popup extends Component {
return (
<Portal
{...mergedPortalProps}
mountNode={mountNode}
onClose={this.handleClose}
onMount={this.handlePortalMount}
onOpen={this.handleOpen}
Expand Down Expand Up @@ -349,6 +355,9 @@ Popup.propTypes = {
/** Invert the colors of the Popup. */
inverted: PropTypes.bool,

/** The node where the popup should mount. Defaults to document.body. */
mountNode: PropTypes.any,

/**
* Offset values in px unit to apply to rendered popup. The basic offset accepts an
* array with two numbers in the form [skidding, distance]:
Expand Down