Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fabric): cherry-pick some View related fixes #2281

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#import <react/utils/ManagedObjectWrapper.h>
#import "RCTLegacyViewManagerInteropCoordinatorAdapter.h"

#if TARGET_OS_OSX // [macOS
#import <React/RCTView.h>
#endif // macOS]

using namespace facebook::react;

static NSString *const kRCTLegacyInteropChildComponentKey = @"childComponentView";
Expand Down Expand Up @@ -210,8 +214,14 @@ - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask
};

if (!_adapter) {
#if !TARGET_OS_OSX // [macOS]
_adapter = [[RCTLegacyViewManagerInteropCoordinatorAdapter alloc] initWithCoordinator:[self _coordinator]
reactTag:self.tag];
#else // [macOS
_adapter = [[RCTLegacyViewManagerInteropCoordinatorAdapter alloc] initWithCoordinator:[self _coordinator]
reactTag:self.reactTag.integerValue];
#endif // macOS]

_adapter.eventInterceptor = ^(std::string eventName, folly::dynamic event) {
if (weakSelf) {
__typeof(self) strongSelf = weakSelf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,11 @@ - (void)invalidateLayer
return;
}

#if TARGET_OS_OSX // [macOS
// clipsToBounds is stubbed out on macOS because it's not part of NSView
layer.masksToBounds = self.clipsToBounds;
#endif // macOS]

const auto borderMetrics = _props->resolveBorderMetrics(_layoutMetrics);

// Stage 1. Shadow Path
Expand Down
4 changes: 3 additions & 1 deletion packages/react-native/React/Views/RCTView.m
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ - (RCTPlatformView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event // [macOS
#if !TARGET_OS_OSX // [macOS]
pointForHitTest = [subview convertPoint:point fromView:self];
#else // [macOS
if ([subview isKindOfClass:[RCTView class]]) {
// Paper and Fabric components use the target view coordinate space for hit testing
if ([subview isKindOfClass:[RCTView class]] || [subview respondsToSelector:@selector(updateProps:oldProps:)]) {
pointForHitTest = [subview convertPoint:point fromView:self];
} else {
// Native macOS views require the point to be in the super view coordinate space for hit testing.
pointForHitTest = point;
}
#endif // macOS]
Expand Down
Loading