Skip to content

Commit ce23bbb

Browse files
t3dotggclaude
andcommitted
fix(web): listen for render heights from the frame's first commit
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent dcf73d0 commit ce23bbb

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎apps/web/src/components/files/BrowserDocumentFrame.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
readHtmlRenderContentHeight,
66
readHtmlRenderLinkRequest,
77
} from "@t3tools/shared/htmlRender";
8-
import { useEffect, useRef, useState } from "react";
8+
import { useEffect, useLayoutEffect, useRef, useState } from "react";
99

1010
import { useHtmlRenderTheme } from "~/hooks/useHtmlRenderTheme";
1111
import { cn } from "~/lib/utils";
@@ -106,7 +106,9 @@ export function HtmlRenderDocument(props: {
106106
return () => window.removeEventListener("message", openLink);
107107
}, []);
108108
const { onContentHeight } = props;
109-
useEffect(() => {
109+
// A page posts its height once per change, so listen from the commit that
110+
// inserts the frame; a passive effect could run after a fast page's first post.
111+
useLayoutEffect(() => {
110112
if (onContentHeight === undefined) return;
111113
const resize = (event: MessageEvent) => {
112114
const height = readHtmlRenderContentHeight(event.data);

0 commit comments

Comments
 (0)