Skip to content

fix(tailwind): split two-value logical shorthands with auto/var/calc#3595

Open
yashs33244 wants to merge 1 commit into
resend:canaryfrom
yashs33244:fix/tailwind-logical-shorthand-split
Open

fix(tailwind): split two-value logical shorthands with auto/var/calc#3595
yashs33244 wants to merge 1 commit into
resend:canaryfrom
yashs33244:fix/tailwind-logical-shorthand-split

Conversation

@yashs33244

@yashs33244 yashs33244 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What

separteShorthandDeclaration splits logical shorthands (margin-inline, margin-block, padding-inline, padding-block) into per-side longhands for email-client compatibility. It decides whether a value has one or two parts by filtering the value's children to Dimension | Number | Percentage:

.filter((child) =>
  child.type === 'Dimension' || child.type === 'Number' || child.type === 'Percentage')

A non-numeric component like auto, var(...) or calc(...) is dropped by that filter, so a genuinely two-value shorthand looks like one value and is not split. Both longhands then receive the full two-value string, which is invalid:

margin-inline: 1rem auto            ->  margin-right:1rem auto; margin-left:1rem auto   // invalid
padding-inline: 10px calc(1rem+2px) ->  padding-right:10px calc(…); padding-left:10px calc(…)

Fix

Count every real value component (everything that isn't an Operator/WhiteSpace) so the two parts are detected and split correctly:

margin-inline: 1rem auto             ->  margin-right:auto; margin-left:1rem
padding-inline: 10px calc(1rem + 2px) ->  padding-right:calc(1rem + 2px); padding-left:10px

Single values (margin-inline: auto, mx-auto) and existing numeric two-value cases are unchanged. Added regression tests; all tailwind tests pass.


Summary by cubic

Fixes splitting of two-value logical shorthands (margin-inline, padding-inline) when one side is auto, var(), or calc(), so we emit valid per-side longhands for email clients.

  • Bug Fixes
    • Count all non-operator/whitespace tokens when parsing shorthand values to detect two parts; single values and numeric pairs are unchanged.
    • Added regression tests for 1rem auto, 0 auto, and 10px calc(1rem + 2px) in react-email.

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

Review in cubic

separteShorthandDeclaration only counted Dimension/Number/Percentage
value components, so a two-value margin-inline/padding-inline with a
non-numeric side (auto, var(), calc()) was seen as one value and not
split - both longhands got the full two-value string, which is invalid.
Count every non-operator/whitespace component instead.
Copilot AI review requested due to automatic review settings June 23, 2026 08:59
@vercel

vercel Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

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

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@changeset-bot

changeset-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cd6e74e

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

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

No issues found across 3 files

Confidence score: 5/5

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

Auto-approved: Fixes a bug in logical shorthand splitting for non-numeric values (auto, var, calc). Changes are isolated, well-tested, and low-risk.

Re-trigger cubic

@github-actions github-actions Bot added the linear-synced PR has been synced to Linear label Jun 23, 2026
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.

2 participants