Skip to content

Commit e5426cc

Browse files
Nick LefeverSaadnajmi
authored andcommitted
[fabric] Fix hit testing calls going through LegacyViewManagerInteropComponent
Summary: Hit testing in RN macOS uses the view coordinate space instead of the macOS superview coordinate space. The RCTView hitTest implementation gets called from Fabric when Paper components are loaded through the `LegacyViewManagerInteropComponent`. When the Paper component has Fabric child components, the hitTest implementation would treat those as native macOS views. This diff adds a selector check to detect Fabric RCTViewComponentView instances and apply the right point conversion. The selector check allows to have the right behavior without having to import Fabric classes in Paper code. Test Plan: - Run Workplace Chat with Fabric enabled - Click on a thread title in the thread list - With the fix, the thread gets selected Reviewers: shawndempsey, ericroz, chpurrer, #rn-desktop Reviewed By: shawndempsey, ericroz Differential Revision: https://phabricator.intern.facebook.com/D49083593 Tasks: T163162857
1 parent 7ce4b0c commit e5426cc

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/react-native/React/Views/RCTView.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,11 @@ - (RCTPlatformView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event // [macOS
256256
#if !TARGET_OS_OSX // [macOS]
257257
pointForHitTest = [subview convertPoint:point fromView:self];
258258
#else // [macOS
259-
if ([subview isKindOfClass:[RCTView class]]) {
259+
// Paper and Fabric components use the target view coordinate space for hit testing
260+
if ([subview isKindOfClass:[RCTView class]] || [subview respondsToSelector:@selector(updateProps:oldProps:)]) {
260261
pointForHitTest = [subview convertPoint:point fromView:self];
261262
} else {
263+
// Native macOS views require the point to be in the super view coordinate space for hit testing.
262264
pointForHitTest = point;
263265
}
264266
#endif // macOS]

0 commit comments

Comments
 (0)