Skip to content

fix(editor): preserve button href through HTML round-trip#3217

Merged
bukinoshita merged 2 commits intocanaryfrom
fix/button-href-roundtrip-9673
Apr 13, 2026
Merged

fix(editor): preserve button href through HTML round-trip#3217
bukinoshita merged 2 commits intocanaryfrom
fix/button-href-roundtrip-9673

Conversation

@bukinoshita
Copy link
Copy Markdown
Member

@bukinoshita bukinoshita commented Apr 9, 2026

Summary

The button extension serializes href into a data-href attribute in renderHTML but never maps it back during parseHTML. This means any HTML round-trip (e.g. getHTML() → setContent(), copy/paste, or persist/reload) causes the button's link to be lost, falling back to the default #.

@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 13, 2026 5:47pm
react-email-demo Ready Ready Preview, Comment Apr 13, 2026 5:47pm
react-email-examples Ready Ready Preview, Comment Apr 13, 2026 5:47pm

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 9, 2026

⚠️ No Changeset found

Latest commit: 571573c

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.

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

💥 An error occurred when fetching the changed packages and changesets in this PR
Some errors occurred when validating the changesets config:
The package "playground" depends on the ignored package "email-dev", but "playground" is not being ignored. Please add "playground" to the `ignore` option.

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 Apr 9, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@react-email/editor@3217

commit: 571573c

@bukinoshita
Copy link
Copy Markdown
Member Author

@cursor can you fix conflicts please?

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 13, 2026

Conflicts resolved. I rebased the branch onto the latest canary, which had changed @react-email/components imports to react-email. The conflict was in button.spec.tsx where the import path diverged — I kept the new react-email import and preserved all the round-trip test additions. All 42 test files pass and the branch has been force-pushed.

Open in Web Open in Cursor 

The button extension was serializing href only as data-href in
renderHTML, and parseHTML never mapped data-href back to href.
This caused buttons to lose their link (falling back to '#') after
any HTML round-trip (getHTML -> setContent, copy/paste, persist/reload).

Changes:
- renderHTML: emit both href and data-href attributes on the <a> tag
- parseHTML: map data-href back to href when building node attributes
- Add tests for full round-trip and data-href-only parsing

Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
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.

3 participants