diff --git a/src/app/(main)/websites/[websiteId]/WebsiteDetails.tsx b/src/app/(main)/websites/[websiteId]/WebsiteDetails.tsx index ceedfe0b5..89c835d8b 100644 --- a/src/app/(main)/websites/[websiteId]/WebsiteDetails.tsx +++ b/src/app/(main)/websites/[websiteId]/WebsiteDetails.tsx @@ -1,7 +1,6 @@ 'use client'; import { Loading } from 'react-basics'; import { usePathname } from 'next/navigation'; -import { useEffect } from 'react'; import Page from 'components/layout/Page'; import FilterTags from 'components/metrics/FilterTags'; import { useNavigation, useWebsite } from 'components/hooks'; @@ -22,26 +21,6 @@ export default function WebsiteDetails({ websiteId }: { websiteId: string }) { const showLinks = !pathname.includes('/share/'); const { view, ...params } = query; - useEffect(() => { - function sendHeightToParent() { - const height = document.body.scrollHeight; - window.parent.postMessage({ height: height }, '*'); - } - - sendHeightToParent(); - - // Add event listener for resize - window.addEventListener('resize', () => { - sendHeightToParent(); - }); - - // Cleanup function to remove event listener - return () => { - window.removeEventListener('resize', () => { - sendHeightToParent(); - }); - }; - }, []) return ( <> {showLinks && } diff --git a/src/app/share/[...shareId]/SharePage.tsx b/src/app/share/[...shareId]/SharePage.tsx index d0e32a293..3b94c7ed9 100644 --- a/src/app/share/[...shareId]/SharePage.tsx +++ b/src/app/share/[...shareId]/SharePage.tsx @@ -1,6 +1,7 @@ 'use client'; import WebsiteDetails from 'app/(main)/websites/[websiteId]/WebsiteDetails'; import { useShareToken } from 'components/hooks'; +import { useEffect } from 'react'; import Page from 'components/layout/Page'; import Header from './Header'; import styles from './SharePage.module.css'; @@ -11,7 +12,26 @@ export default function SharePage({ shareId }) { if (isLoading || !shareToken) { return null; } + useEffect(() => { + function sendHeightToParent() { + const height = document.body.scrollHeight; + window.parent.postMessage({ height: height }, '*'); + } + sendHeightToParent(); + + // Add event listener for resize + window.addEventListener('resize', () => { + sendHeightToParent(); + }); + + // Cleanup function to remove event listener + return () => { + window.removeEventListener('resize', () => { + sendHeightToParent(); + }); + }; + }, []) return (