Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(previews): give both template hosts a definite height so page roots fill them (#5665)

Ernest8692106e2f80
diff --git a/apps/docsite/src/components/TemplatePreviewSurface.module.css b/apps/docsite/src/components/TemplatePreviewSurface.module.css
index df04fa8626..dfc6ea6357 100644
--- a/apps/docsite/src/components/TemplatePreviewSurface.module.css
+++ b/apps/docsite/src/components/TemplatePreviewSurface.module.css
@@ -1,8 +1,8 @@
/* Copyright (c) Meta Platforms, Inc. and affiliates. */
-/* The preview "window". A fixed-height frame (flex-filled by the page
- wrapper) that contains the live template. It does not scroll itself —
- the template's own content region is the single scroll container. */
+/* The preview "window". A fixed-height frame (flex-filled by the dialog)
+ that contains the live template. Fill-mode templates scroll their own
+ content region; auto-height templates can still fall back to this frame. */
.frame {
position: relative;
width: 100%;
@@ -22,3 +22,20 @@
templates read as a real themed app surface. */
background-color: var(--color-background-surface);
}
+
+/* Templates render inline in the docsite, so 100dvh would otherwise resolve
+ against the browser viewport instead of this shorter preview window. Give
+ every page a definite preview-sized containing block, then normalize its
+ first rendered root. The scoped !important declarations intentionally beat
+ template inline height/min-height values such as 100dvh. Overflow remains
+ on `.frame`, so genuinely taller auto-height pages are still reachable. */
+.viewport {
+ width: 100%;
+ height: 100%;
+ min-height: 0;
+}
+
+.viewport > :first-child {
+ height: 100% !important;
+ min-height: 100% !important;
+}
diff --git a/apps/docsite/src/components/TemplatePreviewSurface.tsx b/apps/docsite/src/components/TemplatePreviewSurface.tsx
index f06785400f..c2a6e79d87 100644
--- a/apps/docsite/src/components/TemplatePreviewSurface.tsx
+++ b/apps/docsite/src/components/TemplatePreviewSurface.tsx
@@ -3,12 +3,13 @@
'use client';
/**
- * TemplatePreviewSurface — the live preview "window" for one template.
+ * @file TemplatePreviewSurface.tsx
+ * @input Uses the shared template component registry and current theme mode.
+ * @output Renders one live page template inside a preview-sized viewport.
+ * @position Shared preview surface used by TemplatePreviewDialog.
*
- * Renders the template's real page.tsx component (shared
- * TEMPLATE_COMPONENTS map) at true scale inside the framed, internally-
- * scrollable surface (see TemplatePreviewSurface.module.css `.frame`).
- * Used by the preview dialog (TemplatePreviewDialog).
+ * The viewport wrapper gives percentage-height templates a definite containing
+ * block and normalizes viewport-sized template roots to the dialog preview.
*/
import {Suspense} from 'react';
@@ -49,7 +50,9 @@ export function TemplatePreviewSurface({slug}: {slug: string}) {
</div>
}>
<Theme theme={neutralTheme} mode={mode}>
- <Component />
+ <div className={css.viewport}>
+ <Component />
+ </div>
</Theme>
</Suspense>
) : (
diff --git a/apps/template-viewer/src/index.css b/apps/template-viewer/src/index.css
index 3c614f2227..c01b9c4d2a 100644
--- a/apps/template-viewer/src/index.css
+++ b/apps/template-viewer/src/index.css
@@ -4,3 +4,13 @@
:root {
--stylex-injection: 0;
}
+
+/* `Layout height="fill"` resolves to `height: 100%`, which needs a definite
+ height on every ancestor to mean anything. Without this the chain is auto
+ all the way up, `fill` silently degrades to `auto`, and a pinned footer
+ drifts with the length of whatever step is showing. */
+html,
+body,
+#root {
+ height: 100%;
+}