Skip to content

fix(storybook): screenshots cut off horizontally in Vitest integration#336

Merged
gregberge merged 2 commits into
mainfrom
fix/vitest-screenshot-horizontal-cut-off
Jul 7, 2026
Merged

fix(storybook): screenshots cut off horizontally in Vitest integration#336
gregberge merged 2 commits into
mainfrom
fix/vitest-screenshot-horizontal-cut-off

Conversation

@gregberge

Copy link
Copy Markdown
Member

Problem

Follow-up to #335 (which fixed vertical clipping). The same iframe-clipping issue also happens horizontally.

The story renders inside an <iframe data-vitest="true"> and Argos screenshots the iframe's <body>. With fitToContent, the content is fit in both dimensions (width: fit-content; zoom), but the iframe was only grown vertically. Content wider than the viewport therefore overflows the iframe's width and is left unpainted — the screenshot ends up with a large blank area on the right.

This PR (step 1 — repro only)

Adds a Repro/WideContent story: fixed-width content (2400px) wider than the viewport, with fitToContent. On main this produces a screenshot whose canvas is the full content width but only the leftmost ~viewport-width is painted (rest blank). The fix is pushed as a follow-up commit so the Argos diff demonstrates the screenshot going from cut → complete.

Note: the non-fitToContent (fullPage) case intentionally keeps viewport width, matching Playwright's fullPage semantics (full height, viewport width), so it is out of scope here.

🤖 Generated with Claude Code

…test

Renders fixed-width content wider than the viewport with `fitToContent`.
Without the fix, the screenshot is cut horizontally: the content is only
painted up to the viewport width and the rest of the canvas is blank.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
argos-js-sdk-reference Ready Ready Preview, Comment Jul 7, 2026 6:58pm

Request Review

Follow-up to the vertical fix. `fitToContent` fits the content in both
dimensions, but the iframe was only grown vertically, so content wider
than the viewport was left unpainted (a blank area on the right of the
screenshot). Grow the iframe width too when `fitToContent` is enabled.
Without `fitToContent` the viewport width is kept, matching Playwright's
`fullPage` semantics (full height, viewport width).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gregberge gregberge merged commit c789f32 into main Jul 7, 2026
68 checks passed
@gregberge gregberge deleted the fix/vitest-screenshot-horizontal-cut-off branch July 7, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant