From 953c92967b5f905af8ced0ff72a12515f0ef7ff8 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Thu, 28 Nov 2024 15:53:57 -0800 Subject: [PATCH] refactor(fabric): Make the diff in `[RCTViewComponentView betterHitTest:withEvent:]` more transparent --- .../Mounting/ComponentViews/View/RCTViewComponentView.mm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index e81b7275158f2a..0ee88bcc58e916 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -660,16 +660,17 @@ - (RCTUIView *)betterHitTest:(CGPoint)point withEvent:(UIEvent *)event // [macOS } for (RCTUIView *subview in [self.subviews reverseObjectEnumerator]) { // [macOS] - // Native macOS views require the point to be in the super view coordinate space for hit testing. [macOS] +#if !TARGET_OS_OSX // [macOS] + RCTUIView *hitView = [subview hitTest:[subview convertPoint:point fromView:self] withEvent:event]; // [macOS] +#else // [macOS + // Native macOS views require the point to be in the super view coordinate space for hit testing. CGPoint hitTestPoint = point; -#if TARGET_OS_OSX // [macOS // Fabric components use the target view coordinate space for hit testing if ([subview isKindOfClass:[RCTViewComponentView class]]) { hitTestPoint = [subview convertPoint:point fromView:self]; } -#endif // macOS] - RCTUIView *hitView = [subview hitTest:hitTestPoint withEvent:event]; // [macOS] +#endif // macOS] if (hitView) { return hitView; }