Skip to content

fix(preview): increase whitespace padding to 200 chars for Gmail#3100

Open
mvanhorn wants to merge 4 commits into
resend:canaryfrom
mvanhorn:osc/2268-preview-whitespace-200
Open

fix(preview): increase whitespace padding to 200 chars for Gmail#3100
mvanhorn wants to merge 4 commits into
resend:canaryfrom
mvanhorn:osc/2268-preview-whitespace-200

Conversation

@mvanhorn
Copy link
Copy Markdown
Contributor

@mvanhorn mvanhorn commented Mar 21, 2026

Summary

Increases PREVIEW_MAX_LENGTH from 150 to 200 in the <Preview> component. Gmail shows up to 200 characters of preview text, so the previous 150-character limit left a gap where body content could bleed through into the email preview snippet.

Changes

  • packages/preview/src/preview.tsx: Changed PREVIEW_MAX_LENGTH constant from 150 to 200
  • packages/preview/src/preview.spec.tsx: Updated inline snapshots and assertions to match the new limit

The renderWhiteSpace() function and substring() truncation both reference this constant, so all behavior updates automatically.

Testing

  • All 5 existing tests pass after snapshot update
  • Verified the whitespace padding div now contains 200 repetitions for short text
  • Long text (>200 chars) still truncates correctly with no whitespace padding

Fixes #2268

This contribution was developed with AI assistance (Claude Code).


Summary by cubic

Pads email preview text to 200 chars in @react-email/preview to match Gmail and prevent body content from bleeding into snippets. Updates the Preview component limit and refreshes related snapshots; long text still truncates.

  • Changes: set PREVIEW_MAX_LENGTH to 200 in packages/react-email/src/components/preview/preview.tsx; updated inline snapshots in packages/react-email preview tests, CLI export test, and packages/ui test; added a changeset for @react-email/preview.

Written for commit aa54282. Summary will update on new commits. Review in cubic

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 21, 2026

@mvanhorn is attempting to deploy a commit to the resend Team on Vercel.

A member of the Team first needs to authorize it.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 21, 2026

🦋 Changeset detected

Latest commit: aa54282

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 21, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@react-email/preview@3100
npm i https://pkg.pr.new/@react-email/preview-server@3100
npm i https://pkg.pr.new/react-email@3100

commit: f1f6f04

@gabrielmfern
Copy link
Copy Markdown
Member

can you confirm this doesn't include extra whitespaces for other email clients?

@mvanhorn
Copy link
Copy Markdown
Contributor Author

The whitespace padding uses zero-width Unicode characters (U+200C, U+200D, U+200E, U+200F, U+FEFF) in a hidden div with display:none. These characters are invisible across all email clients - they're the same characters already used at the 150-char limit, just extended to 200. Tested rendering in the preview server and the output is identical except for the padding count. No visible whitespace is added to the email body.

@github-actions github-actions Bot added the linear-synced PR has been synced to Linear label May 14, 2026
@dielduarte dielduarte removed the linear-synced PR has been synced to Linear label May 14, 2026
@github-actions github-actions Bot added the linear-synced PR has been synced to Linear label May 14, 2026
@mvanhorn
Copy link
Copy Markdown
Contributor Author

Hey @gabrielmfern, gentle ping on this -- the answer to your March question is in the comment above (zero-width Unicode chars in a display:none div, no visible whitespace added to the email body). Happy to rebase against canary if you want to take another look.

@dielduarte
Copy link
Copy Markdown
Contributor

Hey @mvanhorn, sorry for our delay on this. Can you please do a rebase? That would indeed help move this one to the finish line! thanks!

mvanhorn and others added 4 commits May 15, 2026 08:31
Gmail shows up to 200 characters of preview text, but the Preview
component only padded to 150 characters. This left a 50-character gap
where body content could bleed into the preview snippet.

Fixes resend#2268

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The CLI's email export test also has an inline snapshot that references
the Preview component output. Updated to match the new 200-char limit.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mvanhorn mvanhorn force-pushed the osc/2268-preview-whitespace-200 branch from 5783822 to aa54282 Compare May 15, 2026 15:31
@mvanhorn
Copy link
Copy Markdown
Contributor Author

Rebased onto canary (aa54282). All 4 commits replayed cleanly, no conflicts.

Ready for another look whenever you have a minute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

linear-synced PR has been synced to Linear

Projects

None yet

Development

Successfully merging this pull request may close these issues.

<Preview> only fills whitespace to 150 chars while Gmail shows up to 200 chars.

3 participants