import React, { useEffect, useRef } from 'react'; import Dialog from '../Modal/Dialog'; import DialogContextProvider from '../../context/DialogContextProvider'; import ReactDOM from 'react-dom'; import { appendToBody } from '../../utils/helpers'; export interface StaticDialogProps { children: React.ReactNode; title?: string; className?: string; defaultBodyOverflow?: string; showCloseIcon?: boolean; isCanClose?: boolean; isBodyScrollLocked?: boolean; isFocusLock?: boolean; replaceScrollBar?: boolean; scrollBarPlaceholderColor?: string; onAfterClose?: (result?: T) => void; onAfterOpen?: () => void; isOpen: boolean; } export default function StaticDialog(props: StaticDialogProps): JSX.Element { const activeElement = useRef(); useEffect(() => { if (props.isOpen) { activeElement.current = document.activeElement as HTMLElement; } else if (activeElement.current) { activeElement.current.focus(); activeElement.current = null; } }, [props.isOpen]); return ReactDOM.createPortal( , appendToBody('stfMountedDialogPlace') ); }