diff --git a/packages/components/src/components/ui/Modal.tsx b/packages/components/src/components/ui/Modal.tsx index f688e17c..e18631cb 100644 --- a/packages/components/src/components/ui/Modal.tsx +++ b/packages/components/src/components/ui/Modal.tsx @@ -2,10 +2,8 @@ import { motion } from "framer-motion"; import React, { useContext } from "react"; import * as ReactDOM from "react-dom"; import { XIcon } from "@heroicons/react/solid"; -import { SquiggleContainer } from "../SquiggleContainer"; import clsx from "clsx"; import { useWindowScroll, useWindowSize } from "react-use"; -import { rectToClientRect } from "@floating-ui/core"; type ModalContextShape = { close: () => void; @@ -79,15 +77,16 @@ const ModalWindow: React.FC<{ } | undefined; - const { clientWidth: screenWidth, clientHeight: screenHeight } = - document.documentElement; - if (container) { - const rect = container?.getBoundingClientRect(); + // If available space in `visibleRect` is smaller than these, fallback to positioning in the middle of the screen. + const minWidth = 384; + const minHeight = 300; + const offset = 8; + const naturalWidth = 576; // maximum possible width; modal tries to take this much space, but can be smaller - // If available space in `visibleRect` is smaller than these, fallback to positioning in the middle of the screen. - const minWidth = 384; // matches the w-96 below - const minHeight = 300; - const offset = 8; + if (container) { + const { clientWidth: screenWidth, clientHeight: screenHeight } = + document.documentElement; + const rect = container?.getBoundingClientRect(); const visibleRect = { left: Math.max(rect.left, 0), @@ -116,15 +115,17 @@ const ModalWindow: React.FC<{ return (