Skip to content

fix(iOS): don't apply padding twice to legacy interop views - #60456

Open
nej1044 wants to merge 1 commit into
react:mainfrom
nej1044:fix/ios-legacy-interop-padding
Open

nej1044 wants to merge 1 commit into
react:mainfrom
nej1044:fix/ios-legacy-interop-padding

Conversation

@nej1044

@nej1044 nej1044 commented Dec 2, 2026

Copy link
Copy Markdown

Summary:

On iOS with the New Architecture, a legacy (Paper) component rendered through the interop layer applies its padding twice when it has children.

RCTLegacyViewManagerInteropComponentView sets the paper view as its contentView. RCTViewComponentView places contentView at layoutMetrics.getContentFrame(), which is the frame inset by padding and border. The paper view's children are mounted directly into the paper view, though, and Yoga computes their frames relative to the outer frame, so those frames already include the padding. The result:

  • the legacy view itself shrinks by the padding on every side
  • its children are pushed right and down by the padding a second time, so they overflow the legacy view on the right and bottom

A common case is react-native-linear-gradient used as a gradient border:

<LinearGradient colors={['#BA7CE5', '#2D97F9']} style={{padding: 1, borderRadius: 12}}>
  <View style={{borderRadius: 11, backgroundColor: '#f4f5fb'}}>{/* ... */}</View>
</LinearGradient>

On Paper and on Android, a 1px gradient border shows on all four sides. On iOS with the New Architecture it shows only on the top and left edges, because the child covers the right and bottom edges. Larger paddings visibly shift the content. Related reports: react-native-linear-gradient/react-native-linear-gradient#677 and #668, and #48114.

The fix keeps the paper view at the component view's full bounds, matching Paper. Children positions are unchanged because they already come from Yoga.

Changelog:

[IOS] [FIXED] - Legacy interop components no longer apply padding twice (the native view shrank and its children were offset)

Test Plan:

Tested in a production app on React Native 0.81.6 with the New Architecture on an iPhone 15 (iOS 26), applying the same change as a patch.

  • Before: a LinearGradient with padding: 1 wrapping an opaque card shows the gradient border only on the top and left edges.
  • After: the border shows on all four sides, the same as on Paper.

Other LinearGradient usages in the app that have larger paddings (16–37px) now lay out the same as on Paper.

The interop component view sets the paper view as its contentView, and
RCTViewComponentView places contentView at the layout content frame (inset
by padding/border). The paper view's children, however, are mounted directly
into it with frames computed by Yoga relative to the outer frame, which
already include the padding. As a result the padding is applied twice: the
legacy view shrinks by the padding while its children are pushed out by it.

Keep the paper view at the full bounds, matching Paper.
@meta-cla

meta-cla Bot commented Dec 2, 2026

Copy link
Copy Markdown

Hi @nej1044!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@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 Dec 2, 2026
@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 Dec 2, 2026
@meta-cla

meta-cla Bot commented Dec 2, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@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 Dec 2, 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.

1 participant