trigger
trigger copied to clipboard
Need access to popupContainer element.
I am using rc-slider and I need to set the z-index for the element created by getContainer. I also propose putting this logic inside componentDidMount() and clean up in componentWillUnmount.
Alternatively you could set the styling for the element within the portal. Right now it's a bit tricky to work with.
getContainer = () => {
const { props } = this;
const popupContainer = document.createElement('div');
// Make sure default popup container will never cause scrollbar appearing
// https://github.com/react-component/trigger/issues/41
popupContainer.style.position = 'absolute';
popupContainer.style.top = '0';
popupContainer.style.left = '0';
popupContainer.style.width = '100%';
const mountNode = props.getPopupContainer ?
props.getPopupContainer(findDOMNode(this)) : props.getDocument().body;
mountNode.appendChild(popupContainer);
return popupContainer;
}
Temporary solution:
getDocument={() => {
return {
body: {
appendChild(child) {
child.style.zIndex = 5
document.body.appendChild(child)
}
}
}
}}