Skip to content

Shoot untiled page shots at the viewport's width - #132

Merged
tmashara merged 3 commits into
mainfrom
claude/issue-115
Nov 3, 2026
Merged

tmashara merged 3 commits into
mainfrom
claude/issue-115

Conversation

@tmashara

@tmashara tmashara commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Closes #115

Untiled page shots used page.screenshot({ fullPage: true }) with no clip. Playwright sizes that image by the widest of body and html scroll/offset/client widths. So an off-canvas box hidden by overflow-x: hidden (metabase.com /product/starter at 1440) made the shot about 2× the viewport, with the page squeezed into its left part.

The fix: when the viewport hides horizontal overflow, the untiled page shot is clipped to the viewport's width. The viewport's overflow is html's computed overflow-x, or body's when html's is visible, and "hides" means hidden or clip. The clip's height is 1e6, which Playwright trims to the document's own height, so the height logic is unchanged.

  • A page that really scrolls sideways keeps today's wide shot, so a horizontal-scroll regression still shows as w±.
  • Element shots and the tiled path are unchanged. No new fields in results.json or the report.

Tests

  • offcanvas (new guard rail): the right side parks a box at left: 100% behind body { overflow-x: hidden }. Both sides are taller than the viewport, so both take the same capture path. At 1440 and 375 the test asserts a zero-pixel diff and a right PNG exactly the viewport's width. On main it reads w-1440.
  • appshell (new guard rail): html { overflow: hidden; height: 100% }, with a body that scrolls 3,000px. The test asserts the shot is taller than 3,000px. A clip using documentElement.scrollHeight cuts it to 900.
  • Real overflow is still covered by the existing --accept width-change test (body { min-width: 2000px }), unchanged.

Heads-up for release notes: shots of pages that hide horizontal overflow but have content past the right edge now narrow to the viewport. Accepted entries on those routes go stale once and need re-accepting, in CI. Other pages are unaffected.

🤖 Generated with Claude Code

tmashara and others added 3 commits November 3, 2026 17:48
fullPage sizes the image by the document's widest scroll/offset/client
width, so an off-canvas box hidden by overflow-x widened the PNG and
squeezed the page into its left part. Clip to the same area the tiled
path already uses.

Closes #115

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Linux, a capture beyond a wider-than-viewport document re-resolves the
monospace fallback, so the text differs between sides on main too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A page that really scrolls sideways keeps its wide shot, so the overflow
still shows as a width change. The height is left to Playwright again, so
an app shell whose body scrolls is shot in full.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tmashara
tmashara merged commit 4dec4a0 into main Nov 3, 2026
3 checks passed
@tmashara
tmashara deleted the claude/issue-115 branch November 3, 2026 17:41
@tmashara tmashara mentioned this pull request Nov 4, 2026
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.

Page shots are wider than the viewport when content overflows hidden

1 participant