Commit 1bbe48e9 by Johannes Schill

Create a portal and use it with our popper component (tooltip and popover) to…

Create a portal and use it with our popper component (tooltip and popover) to avoid potential overflow-/zindex-bugs
parent 0a8f23d8
import { PureComponent } from 'react';
import ReactDOM from 'react-dom';
interface Props {
className?: string;
}
export default class BodyPortal extends PureComponent<Props> {
node: HTMLElement = document.createElement('div');
portalRoot = document.body;
constructor(props) {
super(props);
const { className } = this.props;
if (className) {
this.node.classList.add();
}
this.portalRoot.appendChild(this.node);
}
componentWillUnmount() {
this.portalRoot.removeChild(this.node);
}
render() {
return ReactDOM.createPortal(this.props.children, this.node);
}
}
import React, { PureComponent } from 'react';
import BodyPortal from 'app/core/components/Portal/BodyPortal';
import { Manager, Popper as ReactPopper, Reference } from 'react-popper';
import Transition from 'react-transition-group/Transition';
......@@ -38,6 +39,7 @@ class Popper extends PureComponent<Props> {
</Reference>
<Transition in={show} timeout={100} mountOnEnter={true} unmountOnExit={true}>
{transitionState => (
<BodyPortal className="hej">
<ReactPopper placement={placement}>
{({ ref, style, placement, arrowProps }) => {
return (
......@@ -59,6 +61,7 @@ class Popper extends PureComponent<Props> {
);
}}
</ReactPopper>
</BodyPortal>
)}
</Transition>
</Manager>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment