Skip to content

fix(editor): Strip trailing empty paragraphs from containers at serialization time#3221

Draft
bukinoshita wants to merge 1 commit intocanaryfrom
fix/strip-trailing-empty-paragraphs-1528
Draft

fix(editor): Strip trailing empty paragraphs from containers at serialization time#3221
bukinoshita wants to merge 1 commit intocanaryfrom
fix/strip-trailing-empty-paragraphs-1528

Conversation

@bukinoshita
Copy link
Copy Markdown
Member

@bukinoshita bukinoshita commented Apr 9, 2026

Summary by cubic

Strip trailing empty paragraphs from container nodes during serialization to prevent <p><br/></p> in exported emails. This removes extra space after buttons, images, and dividers without changing the editor UX and addresses BU-668.

  • Bug Fixes
    • Added stripTrailingEmptyParagraphs and invoke it in composeReactEmail to remove only trailing empty paragraphs from container nodes (keeps one if it’s the only child; preserves content).
    • Added unit and integration tests; behavior aligns with TrailingNode and stops unintended vertical spacing in final HTML.

Written for commit daac083. Summary will update on new commits.

The TrailingNode extension auto-inserts empty paragraphs into containers
for editing UX, but these were serialized into the final email HTML as
<p><br/></p>, adding unintended vertical spacing after non-paragraph
blocks (buttons, images, dividers).

This fix adds a stripTrailingEmptyParagraphs utility that recursively
removes trailing empty paragraphs from container nodes during
serialization in composeReactEmail. The editing experience is preserved
since the fix only applies at export time.

Resolves BU-668

Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 9, 2026

⚠️ No Changeset found

Latest commit: daac083

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Apr 9, 2026

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

Project Deployment Actions Updated (UTC)
react-email Ready Ready Preview, Comment Apr 9, 2026 5:36pm
react-email-demo Ready Ready Preview, Comment Apr 9, 2026 5:36pm
react-email-examples Ready Ready Preview, Comment Apr 9, 2026 5:36pm

Request Review

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 4 files

Confidence score: 5/5

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

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.

2 participants