diff --git a/app/globals.css b/app/globals.css index 1351b7b..506dcb9 100644 --- a/app/globals.css +++ b/app/globals.css @@ -90,6 +90,9 @@ select { } .modal-overlay { + position: fixed; + inset: -1px 0 0; + min-height: calc(100dvh + 1px); background: hsl(var(--foreground) / 0.55); } } diff --git a/components/forecast/day-forecast-modal.tsx b/components/forecast/day-forecast-modal.tsx index 604e085..d149971 100644 --- a/components/forecast/day-forecast-modal.tsx +++ b/components/forecast/day-forecast-modal.tsx @@ -1,6 +1,7 @@ "use client"; import { useEffect, useMemo, useRef } from "react"; +import { createPortal } from "react-dom"; import { AnimatePresence, motion } from "framer-motion"; import { CloudSun, Droplets, Sunrise, Sunset, Wind, X } from "lucide-react"; import { DayForecastCharts } from "@/components/charts/day-forecast-charts"; @@ -55,6 +56,7 @@ export function DayForecastModal({ }) { const { language, locale, t } = useI18n(); const closeButtonRef = useRef(null); + const portalRoot = typeof document === "undefined" ? null : document.body; const maximumWind = useMemo(() => getMaximumWind(hours), [hours]); useEffect(() => { @@ -80,11 +82,11 @@ export function DayForecastModal({ ? new Intl.DateTimeFormat(locale, { weekday: "long", day: "numeric", month: "long", timeZone: "UTC" }).format(new Date(`${day.date}T12:00:00Z`)) : ""; - return ( + const modal = ( {day ? ( ); + + return portalRoot ? createPortal(modal, portalRoot) : null; }