Skip to content

Give paddingBlockStart and paddingBlockEnd precedence over the physical edges - #60382

Open
ide wants to merge 1 commit into
react:mainfrom
expo:@ide/block-padding-longhands
Open

ide wants to merge 1 commit into
react:mainfrom
expo:@ide/block-padding-longhands

Conversation

@ide

@ide ide commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary:

This proposes a change of behavior, not a bug fix: when a style sets both paddingTop and paddingBlockStart (or paddingBottom and paddingBlockEnd), the block-axis longhand wins instead of the physical edge.

Today the two axes disagree. applyAliasedProps applies paddingBlockStart and paddingBlockEnd only when paddingTop and paddingBottom are undefined, while paddingInlineStart sets Yoga's Start edge, which Yoga resolves before Left (Style::computeLeftEdge), so it already wins over paddingLeft.

The block-axis order comes from #35342, which gave "precedence to specific edges" and described Yoga's precedence as "left > start > horizontal > all". But for padding Yoga resolved start before left then (YGNode::computeEdgeValueForRow at 67b8e182fa) and does today, as #41682 notes. This change makes the block axis match the inline one. Yoga has no block-start or block-end edge, so the longhands replace the physical edges in applyAliasedProps.

Web parity

On the web, padding-top and padding-block-start set the same side in a horizontal writing mode, and the later declaration wins. React Native flattens styles by key, so no declaration order reaches layout, and neither rule matches the web in every case:

Style Web main This change
paddingTop: 0 then paddingBlockStart: 8 8 0 8
paddingBlockStart: 8 then paddingTop: 0 0 0 8

So this does not improve web parity in general; it changes which order matches. It gives one rule for padding on both axes: the logical longhand wins over the physical edge.

Motivation

A component library compiled with StyleX for React Native carries paddingTop: 0 from a reset beside a component's paddingBlockStart: 8. React Native applies the 0, and a button is laid out 22 points tall where its design is 38.

Scope

This changes padding only. marginBlockStart/marginBlockEnd, insetBlockStart/insetBlockEnd and borderBlockStartWidth/borderBlockEndWidth still give the physical edge precedence; #59996 gave the border widths that order, and Android's BorderInsets.kt follows it. If the direction is right, they should follow; this PR is limited to padding to settle the direction first.

The shorthands keep their place: paddingBlock sets Yoga's Vertical edge, which paddingTop and paddingBottom still override, as paddingLeft overrides paddingInline (Horizontal).

Changelog:

[GENERAL] [CHANGED] - paddingBlockStart and paddingBlockEnd take precedence over paddingTop and paddingBottom, as paddingInlineStart and paddingInlineEnd do over paddingLeft and paddingRight

Test Plan:

yarn fantom packages/react-native/Libraries/Components/View/__tests__/View-paddingBlockLonghands-itest.js

The new View-paddingBlockLonghands-itest.js lays out a container around a 10×10 child:

  • paddingTop: 0, paddingBlockStart: 8, paddingBottom: 0, paddingBlockEnd: 4 puts the child 8 points down in a container 22 tall. On main it fails: child at 0, container 10 tall.
  • paddingLeft: 0, paddingInlineStart: 8 puts the child 8 points in (passes on main: the inline-axis order).
  • paddingTop and paddingBottom alone still apply, and paddingTop: 2, paddingBlock: 8 still gives 2.

These pass on this branch, as do yarn fantom packages/react-native/Libraries/Components/View packages/react-native/Libraries/StyleSheet, flow full-check, ESLint, Prettier and scripts/clang-format.js --check.

Not run: iOS or Android builds; the change is in shared C++ layout code, which Fantom runs.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 29, 2026
@github-actions github-actions Bot added the Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. label Nov 29, 2026
@ide
ide force-pushed the @ide/block-padding-longhands branch from 2b1a800 to 280f016 Compare November 29, 2026 04:52
…al edges

`paddingBlockStart` and `paddingBlockEnd` are applied only when `paddingTop`
and `paddingBottom` are undefined. The inline-axis longhands set Yoga's
`Start` and `End` edges, which Yoga resolves before `Left` and `Right`, so
`paddingInlineStart` already wins over `paddingLeft` (over `paddingRight` in
RTL). Apply the block-axis longhands whenever they are set, so that on both
axes the logical longhand wins over the physical edge. Margin, inset and
border widths keep their current order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ide
ide force-pushed the @ide/block-padding-longhands branch from 280f016 to 81c4585 Compare November 29, 2026 10:22
@ide
ide marked this pull request as ready for review November 29, 2026 12:03
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Nov 29, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Meta Review Required This PR is considered risky and requires Meta to import it to do more testing before merging. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant