diff --git a/React/Base/RCTUIKit.h b/React/Base/RCTUIKit.h index de7eb1f23202f5..8b2ad3e3d0093f 100644 --- a/React/Base/RCTUIKit.h +++ b/React/Base/RCTUIKit.h @@ -391,7 +391,6 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path); - (void)layoutIfNeeded; - (void)layoutSubviews; -- (NSArray *)reactZIndexSortedSubviews; // [macOS] - (void)setNeedsDisplay; @@ -414,10 +413,6 @@ CGPathRef UIBezierPathCreateCGPathRef(UIBezierPath *path); * Specifies whether focus ring should be drawn when the view has the first responder status. */ @property (nonatomic, assign) BOOL enableFocusRing; -/** - * The z-index of the view. - */ -@property (nonatomic, assign) NSInteger reactZIndex; @end diff --git a/React/Base/macOS/RCTUIKit.m b/React/Base/macOS/RCTUIKit.m index 1c5fba8c651dc7..a5bbe147143a9c 100644 --- a/React/Base/macOS/RCTUIKit.m +++ b/React/Base/macOS/RCTUIKit.m @@ -406,27 +406,6 @@ - (void)layoutSubviews [super layout]; } -- (NSArray *)reactZIndexSortedSubviews -{ - // Check if sorting is required - in most cases it won't be. - BOOL sortingRequired = NO; - for (RCTUIView *subview in self.subviews) { - if (subview.reactZIndex != 0) { - sortingRequired = YES; - break; - } - } - return sortingRequired ? [self.subviews sortedArrayUsingComparator:^NSComparisonResult(RCTUIView *a, RCTUIView *b) { - if (a.reactZIndex > b.reactZIndex) { - return NSOrderedDescending; - } else { - // Ensure sorting is stable by treating equal zIndex as ascending so - // that original order is preserved. - return NSOrderedAscending; - } - }] : self.subviews; -} - - (void)setNeedsDisplay { self.needsDisplay = YES; diff --git a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm index b8219cae3d1cda..ab588bddd7c905 100644 --- a/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm @@ -458,7 +458,6 @@ - (void)setPropKeysManagedByAnimated_DO_NOT_USE_THIS_IS_BROKEN:(NSSetpointerEvents == PointerEventsMode::None || _props->pointerEvents == PointerEventsMode::BoxOnly); - if (needsHitSubview && (![self clipsToBounds] || isPointInside)) { - // Take z-index into account when calculating the touch target. - NSArray *sortedSubviews = [self reactZIndexSortedSubviews]; // [macOS] - - // The default behaviour of UIKit is that if a view does not contain a point, - // then no subviews will be returned from hit testing, even if they contain - // the hit point. By doing hit testing directly on the subviews, we bypass - // the strict containment policy (i.e., UIKit guarantees that every ancestor - // of the hit view will return YES from -pointInside:withEvent:). See: - // - https://developer.apple.com/library/ios/qa/qa2013/qa1812.html - for (RCTUIView *subview in [sortedSubviews reverseObjectEnumerator]) { // [macOS] - CGPoint pointForHitTest = CGPointZero; - if ([subview isKindOfClass:[RCTUIView class]]) { // [macOS] - pointForHitTest = [subview convertPoint:point fromView:self]; - } else { - pointForHitTest = point; - } - hitSubview = (RCTUIView *)[subview hitTest:pointForHitTest]; // [macOS] - if (hitSubview != nil) { - break; - } - } - } - - RCTUIView *hitView = (isPointInside ? self : nil); // [macOS] - - switch (_props->pointerEvents) { - case PointerEventsMode::None: - return nil; - case PointerEventsMode::Auto: - return hitSubview ?: hitView; - case PointerEventsMode::BoxOnly: - return hitView; - case PointerEventsMode::BoxNone: - return hitSubview; - default: - return hitSubview ?: hitView; - } -} -#endif // macOS] static RCTCornerRadii RCTCornerRadiiFromBorderRadii(BorderRadii borderRadii) { diff --git a/React/Views/UIView+React.m b/React/Views/UIView+React.m index 915ddcef3fda18..7d86aa7734fd9d 100644 --- a/React/Views/UIView+React.m +++ b/React/Views/UIView+React.m @@ -413,6 +413,15 @@ - (void)setAccessibilityValueInternal:(NSDictionary *)accessibil self, @selector(accessibilityValueInternal), accessibilityValue, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } +// [macOS +#pragma mark - Hit testing +#if TARGET_OS_OSX +- (RCTPlatformView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event +{ + return [self hitTest:point]; +} +#endif // macOS] + #pragma mark - Debug - (void)react_addRecursiveDescriptionToString:(NSMutableString *)string atLevel:(NSUInteger)level {