Skip to content

fix(editor): resolve theme font sizes against the parent size - #3938

Draft
danilowoz wants to merge 2 commits into
canaryfrom
claude/serene-fermi-iy00lm
Draft

danilowoz wants to merge 2 commits into
canaryfrom
claude/serene-fermi-iy00lm

Conversation

@danilowoz

@danilowoz danilowoz commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Related issue or discussion

Internal report, MES-3088: theme text sizes in the editor do not render at the size typed.

What this changes

Theme font sizes are typed in px and compiled to em. Every size was divided by a fixed 14, not by the size of the element it sits in, so the result depended on the base Text size and on nesting. With Text 15, a Title of 15 rendered at 16.07px and a Title of 14 rendered at 15px.

Sizes still compile to em. What changed is the divisor:

  • Base Text size: unchanged, Text / 14 em, relative to the mail client's default.
  • Explicit component size: size / parent size em. The parent is the base Text size, except list item → list and nested list → list item.
  • Unset sizes: untouched, so the theme ratios (for example Title 2.25em) keep scaling with the base.

With Text 15, Title 15 now compiles to 1em and Title 14 to 14/15 em.

Canvas and email parity for lists:

  • The canvas applied the paragraph rule to paragraphs inside list items and the list rule to nested lists. The serializer applies neither, so sizes compounded on the canvas only. The canvas selectors now match the serializer. Email output is not changed by this part.
  • A Code Block size was multiplied by the inner code tag's 0.92em on the canvas only; that tag now gets 1em when the block has an explicit size.

stylesToCss now calls getMergedCssJs instead of repeating it. No public signature changed.

Behaviour change to review

With the default Text size (14), output is identical to before except for the list chain: a List item size under an explicit List size, and a Nested list size under an explicit List item size, now divide by that parent instead of 14. Saved themes that set both will render those at the typed size, which differs from what they render today.

Known limit

Links, inline code, and list items under a nested list resolve against one static parent, so mixed explicit sizes there can still compound. Noted in a shortcut: comment.

Tests

  • Table test for the resolved em values on Basic and Minimal.
  • Browser spec comparing the computed canvas font size per node with what the serializer returns for a paragraph, a list and a nested list.
  • Unit tests, browser tests, typecheck and lint pass locally.

Checklist

  • I understand the code in this PR and the problem it solves.
  • I read this description, and it accurately describes the change.
  • I added a changeset, or this change doesn't affect a published package.

Generated by Claude Code


Summary by cubic

Fixes editor theme font sizes so typed px sizes render at the size typed. Sizes compile to em but were divided by a fixed 14px; they now divide by the parent element's effective size, so a Title under 15px Text renders at 15px, a list item resolves against the list size, and a nested list against the list item size. The canvas selectors now match the serializer so paragraph, list, and code block sizes no longer compound, and stylesToCss delegates to getMergedCssJs.

With the default 14px Text, email output is unchanged except for saved themes that set a size on both a list and its list item, or a list item and its nested list; those now render at the typed size.

Written for commit 67a3b96. Summary will update on new commits.

View guided diff

Theme font sizes stay in em but are divided by the parent's effective
size instead of a fixed 14px, so a typed size renders at that size.
The canvas no longer applies paragraph and list rules inside lists,
matching what the serializer emits.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ThnJ4aUsDUrDw7cVwSLQT6
@vercel

vercel Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
react-email Ready Ready Preview Nov 27, 2026 10:29am UTC
react-email-demo Ready Ready Preview Nov 27, 2026 10:29am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 67a3b96

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

This PR includes changesets to release 1 package
Name Type
@react-email/editor Patch

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

@pkg-pr-new

pkg-pr-new Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 67a3b96

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

1 issue found across 6 files

Confidence score: 3/5

  • In extension.tsx, nested list items can render at the wrong size because their explicit size compounds with the nested-list size. Resolve each item’s size against its actual containing list.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/editor/src/plugins/email-theming/extension.tsx">

<violation number="1" location="packages/editor/src/plugins/email-theming/extension.tsx:94">
P2: Nested list items reuse the top-level list-item ratio, so an explicit list-item size compounds with the nested-list size instead of rendering at the typed size. Resolve each list item against its actual containing list level in the serializer and corresponding canvas selectors.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

const FONT_SIZE_PARENTS: Partial<
Record<KnownThemeComponents, KnownThemeComponents>
> = {
listItem: 'list',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: Nested list items reuse the top-level list-item ratio, so an explicit list-item size compounds with the nested-list size instead of rendering at the typed size. Resolve each list item against its actual containing list level in the serializer and corresponding canvas selectors.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At packages/editor/src/plugins/email-theming/extension.tsx, line 94:

<comment>Nested list items reuse the top-level list-item ratio, so an explicit list-item size compounds with the nested-list size instead of rendering at the typed size. Resolve each list item against its actual containing list level in the serializer and corresponding canvas selectors.</comment>

<file context>
@@ -86,6 +87,14 @@ export function getThemeComponentKey(
+const FONT_SIZE_PARENTS: Partial<
+  Record<KnownThemeComponents, KnownThemeComponents>
+> = {
+  listItem: 'list',
+  nestedList: 'listItem',
+};
</file context>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is real and is the limit recorded in the shortcut: comment on this constant and in the PR description: a list item has one theme key but two possible parents (a top-level list or a nested list), so one em value cannot be exact for both.

Not fixing it in this PR. It needs per-node resolution in the serializer plus separate canvas selectors per list level, which is a larger change than this fix. The case only shows up when List item and Nested list both have explicit sizes. Leaving the thread open for the PR author to decide on a follow-up.


Generated by Claude Code

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0 issues found across 2 files (changes from recent commits).

Confidence score: 5/5

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

Requires human review: Auto-approval blocked by 1 unresolved issue from previous reviews.

View guided diff | Re-trigger cubic

This branch was successfully deployed

2 active deployments
Preview – react-email-demo — 67a3b968 Deployed Nov 27, 2026 by vercel[bot]
Preview – react-email — 67a3b968 Deployed Nov 27, 2026 by vercel[bot]
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