diff --git a/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/WeeklyReport.tsx b/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/WeeklyReport.tsx index 593d5c96e..0123e04ce 100644 --- a/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/WeeklyReport.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/SodiohomeInstallations/WeeklyReport.tsx @@ -152,12 +152,22 @@ function ReportHtmlFrame({ html }: { html: string }) { const iframe = iframeRef.current; if (!iframe) return; + let resizeObserver: ResizeObserver | null = null; + const updateHeight = () => { try { const doc = iframe.contentDocument || iframe.contentWindow?.document; if (doc?.body) { - const newHeight = doc.body.scrollHeight + 20; + const newHeight = Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight) + 40; if (newHeight > 50) setHeight(newHeight); + + if (!resizeObserver) { + resizeObserver = new ResizeObserver(() => { + const h = Math.max(doc.body.scrollHeight, doc.documentElement.scrollHeight) + 40; + if (h > 50) setHeight(h); + }); + resizeObserver.observe(doc.body); + } } } catch { /* cross-origin safety */ } }; @@ -168,6 +178,7 @@ function ReportHtmlFrame({ html }: { html: string }) { return () => { iframe.removeEventListener('load', updateHeight); timers.forEach(clearTimeout); + resizeObserver?.disconnect(); }; }, [html]); @@ -175,6 +186,7 @@ function ReportHtmlFrame({ html }: { html: string }) {