Skip to content

Commit 67f97a1

Browse files
committed
fix(web): keep an html render's row mounted while its image viewer is open
1 parent 38d987d commit 67f97a1

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

‎apps/web/src/components/chat/HtmlRenderFrame.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export function HtmlRenderFrame(props: {
135135
)}
136136
onContentHeight={fitPage}
137137
onLoad={showPage}
138+
onFullscreenChange={onFullscreenChange}
138139
/>
139140
<div className="absolute end-2 top-2 flex gap-1 opacity-0 transition-opacity duration-150 focus-within:opacity-100 group-hover/html-render:opacity-100 pointer-coarse:opacity-100">
140141
<Tooltip>

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ export function HtmlRenderDocument(props: {
127127
readonly threadRef?: ScopedThreadRef | undefined;
128128
/** Receives the page's content height whenever it changes, so an inline frame can fit it. */
129129
readonly onContentHeight?: (height: number) => void;
130+
/** Reports the image viewer opening and closing, so a virtualized row can stay mounted. */
131+
readonly onFullscreenChange?: ((fullscreen: boolean) => void) | undefined;
130132
/** Called when the page has loaded. */
131133
readonly onLoad?: () => void;
132134
}) {
@@ -290,6 +292,12 @@ export function HtmlRenderDocument(props: {
290292
window.addEventListener("message", openImage);
291293
return () => window.removeEventListener("message", openImage);
292294
}, []);
295+
const { onFullscreenChange } = props;
296+
useEffect(() => {
297+
if (expandedImage === null) return;
298+
onFullscreenChange?.(true);
299+
return () => onFullscreenChange?.(false);
300+
}, [expandedImage, onFullscreenChange]);
293301
const { onContentHeight } = props;
294302
// A page posts its height once per change, so listen from the commit that
295303
// inserts the frame; a passive effect could run after a fast page's first post.

0 commit comments

Comments
 (0)