Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const target = this.getTargetSafe();
if (!this.props.shouldUpdatePosition && target === this._lastTarget && !placementChanged) {
return;
}
this._lastTarget = target;
if (!target) {
this.setState({positionLeft: 0, positionTop: 0, arrowOffsetLeft: null, arrowOffsetTop: null});
return;
}
const overlay = ReactDOM.findDOMNode(this);
const container = getContainer(this.props.container, ownerDocument(this).body);
this.setState(overlayPositionUtils.calcOverlayPosition(this.props.placement, overlay, target, container, this.props.containerPadding));
}
}
setContainer = (props: Props = this.props) => {
this.portalContainerNode = getContainer(
props.container, ownerDocument(this).body,
);
}
onShow() {
let doc = ownerDocument(this);
let container = getContainer(this.props.container, doc.body);
modalManager.add(this, container, this.props.containerClassName);
this._onDocumentKeyupListener = on(doc, 'keyup', this.handleDocumentKeyUp);
this._onFocusinListener = onFocus(this.enforceFocus);
this.focus();
if (this.props.onShow) {
this.props.onShow();
}
},
componentWillReceiveProps(nextProps) {
if (this._overlayTarget && nextProps.container !== this.props.container) {
this._portalContainerNode.removeChild(this._overlayTarget);
this._portalContainerNode = getContainer(nextProps.container, ownerDocument(this).body);
this._portalContainerNode.appendChild(this._overlayTarget);
}
},