Skip to content

Commit f7cd859

Browse files
committed
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.
1 parent 056e7ee commit f7cd859

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

‎packages/react-native/React/Fabric/Mounting/ComponentViews/LegacyViewManagerInterop/RCTLegacyViewManagerInteropComponentView.mm‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,22 @@ + (void)supportLegacyViewManagerWithName:(NSString *)componentName
161161

162162
#pragma mark - RCTComponentViewProtocol
163163

164+
// The legacy (Paper) view must fill the whole component view, as it did in Paper.
165+
// Its children are laid out by Yoga relative to the outer frame (padding already applied),
166+
// so placing the paper view at the content frame applies the padding twice.
167+
- (void)setContentView:(UIView *)contentView
168+
{
169+
[super setContentView:contentView];
170+
contentView.frame = self.bounds;
171+
}
172+
173+
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
174+
oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
175+
{
176+
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
177+
self.contentView.frame = self.bounds;
178+
}
179+
164180
- (void)prepareForRecycle
165181
{
166182
_adapter = nil;

0 commit comments

Comments
 (0)