diff --git a/client/src/javascript/ui/components/Portal.tsx b/client/src/javascript/ui/components/Portal.tsx index a158c29c..d3f39bbc 100644 --- a/client/src/javascript/ui/components/Portal.tsx +++ b/client/src/javascript/ui/components/Portal.tsx @@ -11,12 +11,22 @@ const Portal: FC = ({children}: PortalProps) => { useEffect(() => { mountPoint.current = document.createElement('div'); mountPoint.current.classList.add('portal'); - document.body.appendChild(mountPoint.current); + + const appElement = document.getElementById('app'); + if (appElement == null) { + document.body.appendChild(mountPoint.current); + } else { + appElement.appendChild(mountPoint.current); + } return () => { if (mountPoint.current != null) { ReactDOM.unmountComponentAtNode(mountPoint.current); - document.body.removeChild(mountPoint.current); + if (appElement == null) { + document.body.removeChild(mountPoint.current); + } else { + appElement.removeChild(mountPoint.current); + } } }; }, []);