Skip to content

Commit 8b57eb0

Browse files
committed
fix(web): keep HTML preview close button clear of window controls
1 parent 42da166 commit 8b57eb0

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ScopedThreadRef } from "@t3tools/contracts";
22
import { MinusIcon, PlusIcon, XIcon } from "lucide-react";
33
import { useRef, useState } from "react";
4+
import { useNativeTitlebarHeight } from "~/lib/windowControlsOverlay";
45

56
import { HtmlRenderDocument } from "../files/BrowserDocumentFrame";
67
import { Button } from "../ui/button";
@@ -13,6 +14,7 @@ export function HtmlRenderDialog(props: {
1314
readonly onClose: () => void;
1415
}) {
1516
const [zoom, setZoom] = useState(1);
17+
const titlebarHeight = useNativeTitlebarHeight();
1618
const closeButtonRef = useRef<HTMLButtonElement>(null);
1719
return (
1820
<Dialog open onOpenChange={(open) => !open && props.onClose()}>
@@ -21,6 +23,7 @@ export function HtmlRenderDialog(props: {
2123
showCloseButton={false}
2224
bottomStickOnMobile={false}
2325
className="row-start-1"
26+
style={{ marginTop: titlebarHeight }}
2427
initialFocus={closeButtonRef}
2528
>
2629
<DialogTitle className="sr-only">Expanded {props.title} preview</DialogTitle>
@@ -35,7 +38,10 @@ export function HtmlRenderDialog(props: {
3538
>
3639
<XIcon />
3740
</Button>
38-
<div className="h-[min(86vh,calc(100vh-160px))] overflow-auto overscroll-contain rounded-lg bg-background shadow-2xl ring-1 ring-border/70 [container-type:size]">
41+
<div
42+
className="h-[min(86vh,calc(100vh-160px))] overflow-auto overscroll-contain rounded-lg bg-background shadow-2xl ring-1 ring-border/70 [container-type:size]"
43+
style={{ maxHeight: `calc(100vh - 160px - ${titlebarHeight}px)` }}
44+
>
3945
<div className="h-[100cqh] w-[100cqw]" style={{ zoom }}>
4046
<HtmlRenderDocument
4147
src={props.src}

0 commit comments

Comments
 (0)