diff --git a/app/(events)/events/[...filename]/eventsv2.tsx b/app/(events)/events/[...filename]/eventsv2.tsx index 0a04498b2e..419fbf9bcc 100644 --- a/app/(events)/events/[...filename]/eventsv2.tsx +++ b/app/(events)/events/[...filename]/eventsv2.tsx @@ -1,5 +1,5 @@ "use client"; -import { useMobileHeaderAppearance } from "@/app/components/header-appearance"; +import { HeaderAppearanceMarker } from "@/app/components/header-appearance"; import { Blocks } from "@/components/blocks-renderer"; import { Container } from "@/components/util/container"; import { Section } from "@/components/util/section"; @@ -17,9 +17,9 @@ type EventsV2PageProps = { const EventsV2Page = memo( function EventsV2Page({ tinaProps }: EventsV2PageProps) { const { blocks, appearance } = tinaProps.data.eventsv2; - useMobileHeaderAppearance(appearance ?? null); return (
+
void; -}; -const HeaderAppearanceContext = createContext({ - mobile: {}, - setMobile: () => {}, -}); -export function HeaderAppearanceProvider({ - children, +// The header lives in the root layout and can't see the current page's data, so +// hiding the mobile flag/Contact button used to happen in a client effect AFTER +// hydration — reflowing the header and everything below it (CLS). Instead, the page +// server-renders this hidden marker; CSS in styles.css reads it via `:has()` and hides +// the elements on first paint, so SSR and hydration match. Client-side navigation swaps +// the marker in/out with the page, so the header updates without any header-side JS. +// (Middleware `x-pathname` + server resolution — the other documented fix — was rejected: +// reading headers() in the root layout breaks the `dynamic = "force-static"` routes.) +export function HeaderAppearanceMarker({ + appearance, }: { - children: React.ReactNode; + appearance?: MobileHeaderAppearance | null; }) { - const [mobile, setMobile] = useState({}); - const value = useMemo(() => ({ mobile, setMobile }), [mobile]); + if (!appearance?.hideFlag && !appearance?.hideContactButton) return null; return ( - - {children} - +