Skip to content

fix(docsite): keep the template preview header inside the dialog - #6276

Merged
ernestt merged 1 commit into
mainfrom
fix/template-preview-mobile-overflow
Sep 12, 2026
Merged

ernestt merged 1 commit into
mainfrom
fix/template-preview-mobile-overflow

Conversation

@ernestt

@ernestt ernestt commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

User impact

Anyone opening a template preview from /templates on a phone gets an unusable
dialog: the preview surface and the whole header (title, install commands, Open
in Playground, close) are pushed sideways out of view, and nothing scrolls them
back — the only way out is Escape or a reload.

Repro: load the templates gallery at 393 x 660 CSS px (iPhone 14 Pro), tap any
card. The dialog opens already scrolled ~295px to the side.

Expected behavior and authority

The gallery passes variant="fullscreen" on mobile precisely so the preview is
edge-to-edge and self-contained; a fullscreen dialog's own chrome must stay
inside the viewport it fills. The file header for this component already states
the intent ("Dialog variant — pass 'fullscreen' on mobile for edge-to-edge
preview"), and Dialog's fullscreen variant sizes itself to the dynamic viewport.

Smallest restoration

The header laid the command rows and the primary action on a single line. Its
min-content width is ~976px at the canary target (two command rows), far wider
than a phone, so the header — not the template — pushed the dialog body past the
viewport. The body is clipped with overflow: hidden, which is still
programmatically scrollable: initial focus landed on a control inside the
overflowing area, the browser scrolled it into view, and the clipped box stayed
scrolled with no user-reachable scrollbar to undo it.

The fix makes the header fit rather than overflow:

  • fullscreen (phone) stacks the command rows and a full-width primary action;
    the close button stays pinned to the top-inline-end corner;
  • the standard header wraps when the actions no longer fit beside a 240px title
    block — the same overflow reproduced at tablet width (834px), where the
    actions previously ran ~250px past the dialog edge;
  • command rows shrink and truncate before the buttons do, and the header row is
    capped at 100% width so it can never widen the dialog again.

No new API, no new affordance, no change to what the header offers.

Evidence

Measured in Chromium via Playwright, reading live geometry inside the open
dialog (elements rendered outside the viewport, and clipped containers left with
scrollLeft > 0).

Reproduction before the change — 393 x 660, Grouped Table:

dialog        = 393px wide
body          = 976px scrollWidth inside it
clipped body  = scrollLeft 295  (unreachable; overflow: hidden)
offscreen     = 19 elements, e.g. header row at left -295, title at left -271

Result after the change — same page, same template:

dialog        = 393px wide
offscreen     = 0 elements
scrolled      = 0 clipped containers

Also clean at 320 x 568 and 393 x 660 across Analytics Dashboard, Grouped Table,
Settings Panels, AI Chat Conversation, Product Gallery, Documentation Technical,
IDE and Kanban Board; and at 834, 1024 and 1440 CSS px.

Representative unchanged path: at 1440 x 900 the standard dialog is unchanged —
1400px wide, title left, command rows centre, Open in Playground and close
right, nothing offscreen, nothing scrolled. At 834px the actions now wrap onto a
second row instead of colliding with the title.

Regression-sensitive proof: the probe fails if any element inside the dialog
renders outside the viewport or any clipped container is left scrolled;
reverting the header changes reproduces the 976px min-content width and the
scrolled clipped body.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

  • tsc --noEmit (apps/docsite) and eslint on the changed file — clean.
  • Real-browser states: dialog open at 320, 393, 834, 1024, 1440 CSS px; initial
    focus on open (the state that triggered the scroll); command truncation; close
    button reachable; Open in Playground reachable and full width on phones.

Follow-up (not in this PR)

Dialog's inner body uses overflow: hidden, which stays programmatically
scrollable — that is what turned "content too wide" into "content permanently
off-screen". LayoutContent already uses overflow: clip for its
non-scrollable case. Switching Dialog's inner wrapper to clip would contain
this class of bug for every dialog, but it touches core and belongs in its own
change.

On a phone the preview dialog opened with its whole surface pushed off to
the side: the title, the commands and the close button were all cut off and
no amount of scrolling brought them back.

The header laid its command rows and the primary action out on one line.
That line's min-content width is far wider than a phone (~976px at the
canary target, which shows two command rows), so the header pushed the
dialog body past the viewport. The body is clipped with `overflow: hidden`,
which is still programmatically scrollable: initial focus landed on a
control in the overflowing area, the browser scrolled it into view, and the
clipped box stayed scrolled with no way for a user to scroll it back.

Make the header fit instead:

- fullscreen (phone) stacks the command rows and a full-width primary
  action, with the close button still pinned to the corner;
- the standard header wraps when the actions no longer fit beside a 240px
  title block, which also fixes the same overflow at tablet widths;
- command rows shrink and truncate before the buttons do, and the header
  row is capped at 100% width so it can never widen the dialog again.

Verified in a real browser at 320, 393, 834, 1024 and 1440 CSS px across
dashboard, table, settings, chat, gallery and documentation templates: no
element renders outside the dialog and no clipped container is left
scrolled.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 12, 2026
@vercel

vercel Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 12, 2026 5:05am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟡 Reviewed (for maintainers only) Sep 12, 2026, 5:16 AM UTC

@github-actions

Copy link
Copy Markdown
Contributor

PR Analysis Report

Current run: The current CI run completed, but its trusted analysis is unavailable. Preview links are not shown.


Generated by PR Enrichment workflow | View current CI run

@ernestt
ernestt merged commit 0e3f116 into main Sep 12, 2026
26 checks passed
@github-actions
github-actions Bot deleted the fix/template-preview-mobile-overflow branch September 12, 2026 06:20

This branch was successfully deployed

1 active deployment
Preview — 7703189b Deployed Sep 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant