From 5cbc2e03bc35724bbaa9ba7c2347355905168041 Mon Sep 17 00:00:00 2001 From: Devan Buggay Date: Thu, 15 Jan 2026 18:48:44 -0800 Subject: [PATCH] Remove Surface Handlers for AppleTV Summary: SurfaceTouch and SurfacePointer handlers use a lot of unsupported UIKit APIs. Instead of granuarly wrapping the UIKit usage, this minimally removes the handlers from AppleTV all-together, as they no-op anyways (there is no click-through support on simulator.) Changelog: [Internal] Reviewed By: Abbondanzo Differential Revision: D90704270 --- .../InputAccessory/RCTInputAccessoryComponentView.mm | 4 ++++ .../Modal/RCTFabricModalHostViewController.mm | 6 ++++++ .../react-native/React/Fabric/RCTSurfacePointerHandler.mm | 4 ++++ .../react-native/React/Fabric/RCTSurfaceTouchHandler.mm | 4 ++++ .../react-native/React/Fabric/Surface/RCTFabricSurface.mm | 4 ++++ 5 files changed, 22 insertions(+) diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryComponentView.mm index 9f1f29918a57..cde96f038792 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/InputAccessory/RCTInputAccessoryComponentView.mm @@ -43,7 +43,9 @@ @implementation RCTInputAccessoryComponentView { InputAccessoryShadowNode::ConcreteState::Shared _state; RCTInputAccessoryContentView *_contentView; +#if !TARGET_OS_TV RCTSurfaceTouchHandler *_touchHandler; +#endif UIView __weak *_textInput; } @@ -52,8 +54,10 @@ - (instancetype)initWithFrame:(CGRect)frame if (self = [super initWithFrame:frame]) { _props = InputAccessoryShadowNode::defaultSharedProps(); _contentView = [RCTInputAccessoryContentView new]; +#if !TARGET_OS_TV _touchHandler = [RCTSurfaceTouchHandler new]; [_touchHandler attachToView:_contentView]; +#endif } return self; diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTFabricModalHostViewController.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTFabricModalHostViewController.mm index 16b71e4d64ec..1a4339065e60 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTFabricModalHostViewController.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/Modal/RCTFabricModalHostViewController.mm @@ -12,7 +12,9 @@ @implementation RCTFabricModalHostViewController { CGRect _lastViewBounds; +#if !TARGET_OS_TV RCTSurfaceTouchHandler *_touchHandler; +#endif } - (instancetype)init @@ -20,7 +22,9 @@ - (instancetype)init if ((self = [super init]) == nullptr) { return nil; } +#if !TARGET_OS_TV _touchHandler = [RCTSurfaceTouchHandler new]; +#endif return self; } @@ -37,7 +41,9 @@ - (void)viewDidLayoutSubviews - (void)loadView { self.view = [UIView new]; +#if !TARGET_OS_TV [_touchHandler attachToView:self.view]; +#endif } - (UIStatusBarStyle)preferredStatusBarStyle diff --git a/packages/react-native/React/Fabric/RCTSurfacePointerHandler.mm b/packages/react-native/React/Fabric/RCTSurfacePointerHandler.mm index d752d6ae56b7..fe00a0b3e951 100644 --- a/packages/react-native/React/Fabric/RCTSurfacePointerHandler.mm +++ b/packages/react-native/React/Fabric/RCTSurfacePointerHandler.mm @@ -15,6 +15,8 @@ #import "RCTConversions.h" #import "RCTTouchableComponentViewProtocol.h" +#if !TARGET_OS_TV + using namespace facebook::react; typedef NS_ENUM(NSInteger, RCTPointerEventType) { @@ -771,3 +773,5 @@ - (void)hovering:(UIHoverGestureRecognizer *)recognizer } @end + +#endif // !TARGET_OS_TV diff --git a/packages/react-native/React/Fabric/RCTSurfaceTouchHandler.mm b/packages/react-native/React/Fabric/RCTSurfaceTouchHandler.mm index d8c709fd5061..ea2952c23e78 100644 --- a/packages/react-native/React/Fabric/RCTSurfaceTouchHandler.mm +++ b/packages/react-native/React/Fabric/RCTSurfaceTouchHandler.mm @@ -15,6 +15,8 @@ #import "RCTSurfacePointerHandler.h" #import "RCTTouchableComponentViewProtocol.h" +#if !TARGET_OS_TV + using namespace facebook::react; typedef NS_ENUM(NSInteger, RCTTouchEventType) { @@ -414,3 +416,5 @@ - (void)_cancelTouches } @end + +#endif // !TARGET_OS_TV diff --git a/packages/react-native/React/Fabric/Surface/RCTFabricSurface.mm b/packages/react-native/React/Fabric/Surface/RCTFabricSurface.mm index cf932b52bf00..2a5a3a66346f 100644 --- a/packages/react-native/React/Fabric/Surface/RCTFabricSurface.mm +++ b/packages/react-native/React/Fabric/Surface/RCTFabricSurface.mm @@ -45,7 +45,9 @@ @implementation RCTFabricSurface { // Can be accessed from the main thread only. RCTSurfaceView *_Nullable _view; +#if !TARGET_OS_TV RCTSurfaceTouchHandler *_Nullable _touchHandler; +#endif } @synthesize delegate = _delegate; @@ -144,8 +146,10 @@ - (RCTSurfaceView *)view if (!_view) { _view = [[RCTSurfaceView alloc] initWithSurface:self]; [self _updateLayoutContext]; +#if !TARGET_OS_TV _touchHandler = [RCTSurfaceTouchHandler new]; [_touchHandler attachToView:_view]; +#endif } return _view;