diff --git a/packages/react/src/components/ViewportPortal/index.tsx b/packages/react/src/components/ViewportPortal/index.tsx new file mode 100644 index 00000000..4195a608 --- /dev/null +++ b/packages/react/src/components/ViewportPortal/index.tsx @@ -0,0 +1,19 @@ +import type { ReactNode } from 'react'; +import { createPortal } from 'react-dom'; + +import { useStore } from '../../hooks/useStore'; +import type { ReactFlowState } from '../../types'; + +const selector = (s: ReactFlowState) => s.domNode?.querySelector('.react-flow__viewport-portal'); + +function ViewportPortal({ children }: { children: ReactNode }) { + const viewPortalDiv = useStore(selector); + + if (!viewPortalDiv) { + return null; + } + + return createPortal(children, viewPortalDiv); +} + +export default ViewportPortal; diff --git a/packages/react/src/container/GraphView/index.tsx b/packages/react/src/container/GraphView/index.tsx index 217e90c2..e311bc7f 100644 --- a/packages/react/src/container/GraphView/index.tsx +++ b/packages/react/src/container/GraphView/index.tsx @@ -174,7 +174,7 @@ const GraphView = ({ />
- +