Skip to content

Commit 1092a5f

Browse files
committed
other changes
1 parent 28b2fed commit 1092a5f

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,10 +1010,20 @@ - (RCTUIView *)currentContainerView // [macOS]
10101010
if (_useCustomContainerView) {
10111011
if (!_containerView) {
10121012
_containerView = [[RCTPlatformView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; // [macOS]
1013+
#if TARGET_OS_OSX // [macOS
1014+
_containerView.wantsLayer = YES;
1015+
#endif // macOS]
10131016
for (RCTPlatformView *subview in self.subviews) { // [macOS]
10141017
[_containerView addSubview:subview];
10151018
}
1019+
#if !TARGET_OS_OSX // [macOS]
10161020
_containerView.clipsToBounds = self.clipsToBounds;
1021+
#else // [macOS
1022+
// On macOS, clipsToBounds doesn't automatically set layer.masksToBounds
1023+
// like it does on iOS, so we need to set it directly.
1024+
_containerView.clipsToBounds = _props->getClipsContentToBounds();
1025+
_containerView.layer.masksToBounds = _props->getClipsContentToBounds();
1026+
#endif // macOS]
10171027
self.clipsToBounds = NO;
10181028
_containerView.layer.mask = self.layer.mask;
10191029
self.layer.mask = nil;
@@ -1045,8 +1055,15 @@ - (void)invalidateLayer
10451055
}
10461056

10471057
#if TARGET_OS_OSX // [macOS
1048-
// clipsToBounds is stubbed out on macOS because it's not part of NSView
1049-
layer.masksToBounds = self.clipsToBounds;
1058+
// On macOS, clipsToBounds doesn't automatically set layer.masksToBounds like iOS does.
1059+
// When _useCustomContainerView is true (boxShadow + overflow:hidden), the container
1060+
// view handles clipping children while the main layer stays unclipped for the shadow.
1061+
// The container view's masksToBounds is set in currentContainerView getter.
1062+
if (_useCustomContainerView) {
1063+
layer.masksToBounds = NO;
1064+
} else {
1065+
layer.masksToBounds = _props->getClipsContentToBounds();
1066+
}
10501067
#endif // macOS]
10511068

10521069
const auto borderMetrics = _props->resolveBorderMetrics(_layoutMetrics);
@@ -1184,6 +1201,10 @@ - (void)invalidateLayer
11841201
[layer addSublayer:borderLayer];
11851202
_borderLayer = borderLayer;
11861203
}
1204+
#if TARGET_OS_OSX // [macOS
1205+
// Update frame on every call in case view was resized
1206+
_borderLayer.frame = layer.bounds;
1207+
#endif // macOS]
11871208

11881209
layer.borderWidth = 0;
11891210
layer.borderColor = nil;
@@ -1284,7 +1305,8 @@ - (void)invalidateLayer
12841305
if (!_props->boxShadow.empty()) {
12851306
_boxShadowLayer = [CALayer layer];
12861307
[self.layer addSublayer:_boxShadowLayer];
1287-
_boxShadowLayer.zPosition = _borderLayer.zPosition;
1308+
// Box shadow should be behind all content but still visible
1309+
_boxShadowLayer.zPosition = BACKGROUND_COLOR_ZPOSITION - 1;
12881310
_boxShadowLayer.frame = RCTGetBoundingRect(_props->boxShadow, self.layer.bounds.size);
12891311

12901312
RCTUIImage *boxShadowImage = RCTGetBoxShadowImage( // [macOS]

0 commit comments

Comments
 (0)