From f7cd859a62ca307fd241e0b3965cca30237eb579 Mon Sep 17 00:00:00 2001 From: nej1044 Date: Wed, 2 Dec 2026 12:10:53 +0900 Subject: [PATCH] fix(iOS): don't apply padding twice to legacy interop views 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. --- .../RCTLegacyViewManagerInteropComponentView.mm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm index bbfe97903e01..a9516d2164c0 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm @@ -161,6 +161,22 @@ + (void)supportLegacyViewManagerWithName:(NSString *)componentName #pragma mark - RCTComponentViewProtocol +// The legacy (Paper) view must fill the whole component view, as it did in Paper. +// Its children are laid out by Yoga relative to the outer frame (padding already applied), +// so placing the paper view at the content frame applies the padding twice. +- (void)setContentView:(UIView *)contentView +{ + [super setContentView:contentView]; + contentView.frame = self.bounds; +} + +- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics + oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics +{ + [super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics]; + self.contentView.frame = self.bounds; +} + - (void)prepareForRecycle { _adapter = nil;