Skip to content

Commit 0601fcd

Browse files
fix(files): render HTML files shared via a public file link (#6363)
The public share page rooted on `.desktop-title-bar-page`, which sets only `min-height: 100vh`. Without a definite height, `h-full` on every descendant of `<main>` resolved to `auto` -> 0. `HtmlPreview` gates its sandboxed iframe on a measured non-zero container, so it silently never mounted and the page rendered a blank area under the header. Other read-only branches survived because their content has intrinsic height. Give the public page root a definite height, and make the read-only preview chain flex-based so it fills its parent instead of depending on an ancestor's definite height. `text-editor`'s preview pane becomes a flex column for the same reason -- it is `HtmlPreview`'s other parent.
1 parent 1c0e82a commit 0601fcd

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

apps/sim/app/f/[token]/public-file-view.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ export function PublicFileView({
6666
)
6767

6868
return (
69-
<div className='light desktop-title-bar-page flex flex-col bg-[var(--bg)]'>
69+
<div className='light desktop-title-bar-page flex h-screen flex-col overflow-hidden bg-[var(--bg)]'>
7070
<DesktopTitleBarLane />
71-
<header className='sticky top-[var(--desktop-title-bar-height)] z-10 flex items-center justify-between gap-4 border-[var(--border)] border-b bg-[var(--bg)] px-4 py-3'>
71+
<header className='z-10 flex shrink-0 items-center justify-between gap-4 border-[var(--border)] border-b bg-[var(--bg)] px-4 py-3'>
7272
<div className='flex min-w-0 items-center gap-3'>
7373
{!brand.logoUrl && (
7474
<>

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/file-viewer.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,12 @@ const ReadOnlyTextPreview = memo(function ReadOnlyTextPreview({
284284

285285
const resolvedError = resolvePreviewError((error as Error | null) ?? null, null)
286286
if (resolvedError) return <PreviewError label='file' error={resolvedError} />
287-
if (isLoading || content == null) return <PreviewLoadingFrame className='h-full' tone='surface' />
287+
if (isLoading || content == null)
288+
return <PreviewLoadingFrame className='min-h-0 flex-1' tone='surface' />
288289

289290
if (resolvePreviewType(file.type, file.name)) {
290291
return (
291-
<div className='h-full min-h-0 w-full overflow-auto'>
292+
<div className='flex min-h-0 w-full flex-1 flex-col overflow-auto'>
292293
<PreviewPanel
293294
content={content}
294295
mimeType={file.type}
@@ -302,7 +303,7 @@ const ReadOnlyTextPreview = memo(function ReadOnlyTextPreview({
302303
}
303304

304305
return (
305-
<div className='h-full min-h-0 w-full overflow-auto bg-[var(--surface-1)] p-4'>
306+
<div className='min-h-0 w-full flex-1 overflow-auto bg-[var(--surface-1)] p-4'>
306307
<pre className='whitespace-pre-wrap break-words font-mono text-[13px] text-[var(--text-body)]'>
307308
{content}
308309
</pre>

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/preview-panel.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ const HtmlPreview = memo(function HtmlPreview({ content }: { content: string })
200200
}, [])
201201

202202
return (
203-
<div ref={containerRef} className='h-full overflow-hidden'>
203+
<div ref={containerRef} className='flex min-h-0 flex-1 overflow-hidden'>
204204
{isRenderable && (
205205
<iframe
206206
key={resumeNonce}
@@ -225,7 +225,7 @@ function SvgPreview({ content }: { content: string }) {
225225
}, [content])
226226

227227
return (
228-
<ZoomablePreview className='h-full' contentClassName='h-full w-full'>
228+
<ZoomablePreview className='min-h-0 flex-1' contentClassName='h-full w-full'>
229229
{blobUrl && (
230230
<img
231231
src={blobUrl}
@@ -240,7 +240,7 @@ function SvgPreview({ content }: { content: string }) {
240240

241241
function MermaidFilePreview({ content, isStreaming }: { content: string; isStreaming?: boolean }) {
242242
return (
243-
<div className='h-full overflow-auto p-6'>
243+
<div className='min-h-0 flex-1 overflow-auto p-6'>
244244
<MermaidDiagram
245245
definition={content}
246246
isStreaming={isStreaming}
@@ -267,14 +267,14 @@ const CsvPreview = memo(function CsvPreview({
267267

268268
if (headers.length === 0) {
269269
return (
270-
<div className='flex h-full items-center justify-center p-6'>
270+
<div className='flex min-h-0 flex-1 items-center justify-center p-6'>
271271
<p className='text-[13px] text-[var(--text-muted)]'>No data to display</p>
272272
</div>
273273
)
274274
}
275275

276276
return (
277-
<div className='h-full overflow-auto p-6'>
277+
<div className='min-h-0 flex-1 overflow-auto p-6'>
278278
<DataTable headers={headers} rows={rows} />
279279
</div>
280280
)

apps/sim/app/workspace/[workspaceId]/files/components/file-viewer/text-editor.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,10 @@ export const TextEditor = memo(function TextEditor({
672672
</div>
673673
)}
674674
<div
675-
className={cn('min-w-0 flex-1 overflow-hidden', isResizing && 'pointer-events-none')}
675+
className={cn(
676+
'flex min-w-0 flex-1 flex-col overflow-hidden',
677+
isResizing && 'pointer-events-none'
678+
)}
676679
>
677680
<PreviewPanel
678681
key={previewContextKey ? `${file.id}:${previewContextKey}` : file.id}

0 commit comments

Comments
 (0)