Skip to content

fix(react-email): keep a longhand padding of 0 on Button - #3793

Merged
dielduarte merged 2 commits into
resend:canaryfrom
Abhishek-B-R:fix/button-zero-padding-longhand
Oct 28, 2026
Merged

dielduarte merged 2 commits into
resend:canaryfrom
Abhishek-B-R:fix/button-zero-padding-longhand

Conversation

@Abhishek-B-R

@Abhishek-B-R Abhishek-B-R commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #3792

Intent

Bug fix. <Button style={{ padding: '12px 20px', paddingTop: 0 }}> rendered with 12px of top padding, because the explicit 0 was dropped and the shorthand took over.

What was going on

parsePadding turned each side into px with a truthiness check:

paddingTop: paddingTop ? convertToPx(paddingTop) : undefined,

so the number 0 came back as undefined. Button spreads the user's style (which still contains padding: '12px 20px') and then the parsed longhands on top. React omits undefined style values, so the rendered <a> had

padding:12px 20px;padding-right:20px;padding-left:20px

with no padding-top at all. The Outlook spacer is computed from the parsed values with ?? 0, so it already treated the top as 0, which means Outlook and every other client disagreed about the button height. paddingTop: '0px' was fine because the string is truthy.

Changes

parsePadding now only skips undefined and the empty string, so 0 is converted like any other value. The empty string case keeps its existing behaviour (there is a test for it).

Verification

Two tests, both written before the fix and both failing on canary:

  • parsePadding({ padding: '12px 20px', paddingTop: 0 }) returned paddingTop: undefined, now 0.
  • Rendering the Button above now contains padding-top:0; and padding-bottom:0;.

vitest run in packages/react-email: 304 passed. The one failing test and two failing suites (cli/commands/testing/export*.spec.ts) fail the same way on a clean canary checkout in my environment, so they are unrelated. tsc --noEmit and biome check are clean.

Added a patch changeset for react-email.


Summary by cubic

Fixes <Button> dropping an explicit longhand padding of 0, so style={{ padding: '12px 20px', paddingTop: 0 }} now renders with no top padding instead of falling back to the shorthand's 12px.

convertToPx previously returned 0 for any falsy input, so the number 0 became indistinguishable from unset values and React omitted it from the style, letting the shorthand win. It now only returns undefined for undefined and empty strings, and passes 0 through. Tests cover the parsing and the rendered output, and a patch changeset for react-email is included.

Written for commit 0706e11. Summary will update on new commits.

View guided diff

@changeset-bot

changeset-bot Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0706e11

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

This PR includes changesets to release 3 packages
Name Type
react-email Patch
@react-email/editor Patch
@react-email/ui 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

@vercel

vercel Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

@Abhishek-B-R is attempting to deploy a commit to the resend Team on Vercel.

A member of the Team first needs to authorize it.

@Abhishek-B-R

Copy link
Copy Markdown
Contributor Author

@felipefreitag friendly bump: this makes parsePadding keep an explicit 0 longhand on Button (fixes #3792), so paddingTop: 0 no longer falls back to the shorthand and the rendered padding matches the Outlook spacer. It merges cleanly with canary and includes a changeset; the only failing statuses are the Vercel previews, which need team authorization for fork PRs. Happy to adjust anything if the approach doesn't fit.

@pkg-pr-new

pkg-pr-new Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 0706e11

Abhishek-B-R and others added 2 commits October 28, 2026 16:19
parsePadding returned undefined for a longhand set to the number 0
because it used a truthiness check before converting to px. Button
spreads the original style first and then the parsed longhands, so an
undefined paddingTop is omitted and the padding shorthand wins: with
{ padding: '12px 20px', paddingTop: 0 } the button rendered 12px of top
padding in every client, while the Outlook spacer was computed as if it
were 0.

Only skip undefined and empty strings, so 0 is passed through.
@dielduarte
dielduarte force-pushed the fix/button-zero-padding-longhand branch from 06d0954 to 0706e11 Compare October 28, 2026 20:19
@vercel

vercel Bot commented Oct 28, 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 Oct 28, 2026 8:24pm UTC
react-email-demo Ready Ready Preview Oct 28, 2026 8:24pm UTC

Request Review

@dielduarte dielduarte 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.

thanks @Abhishek-B-R for the contribution! I did refactor the helper to reuse the existing helper instead. approving and merging!

@dielduarte
dielduarte merged commit a959dbb into resend:canary Oct 28, 2026
13 checks passed

This branch was successfully deployed

2 active deployments
Preview – react-email-demo — 0706e110 Deployed Oct 28, 2026 by vercel[bot]
Preview – react-email — 0706e110 Deployed Oct 28, 2026 by vercel[bot]
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.

Button: a longhand padding of 0 is ignored when the padding shorthand is set

2 participants