Skip to content

Commit 3e897cf

Browse files
sbuggaymeta-codesync[bot]
authored andcommitted
Emit tvOS focus events after focus updates (#58372)
Summary: Pull Request resolved: #58372 On tvOS, the focus engine and UIKit first responder are related but distinct. The imperative focus path previously called `becomeFirstResponder` before requesting a focus-engine update. If tvOS rejected that candidate, React Native had already emitted `blur` for the currently focused view and `focus` for the candidate, leaving JavaScript event state out of sync with visual focus. Request the tvOS focus update without changing first responder first. `didUpdateFocusInContext` remains the point that promotes the selected view to first responder and emits events. Successful focus updates retain their focus and blur events, rejected updates emit neither, and non-tvOS behavior is unchanged. Changelog: [iOS][Fixed] - Prevent unsuccessful tvOS focus requests from emitting stale focus events Reviewed By: AnastasiaRainMaker Differential Revision: D119054149 fbshipit-source-id: 71f1fa4f60f46146baf8adaeafd104e041b4bc8c
1 parent 96518a8 commit 3e897cf

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎packages/react-native/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,6 @@ - (UIView *)viewToFocus
18501850
- (void)focus
18511851
{
18521852
UIView *viewToFocus = [self viewToFocus];
1853-
[viewToFocus becomeFirstResponder];
18541853

18551854
#if TARGET_OS_TV
18561855
RCTSurfaceHostingProxyRootView *rootView = [self containingRootView];
@@ -1861,6 +1860,8 @@ - (void)focus
18611860
rootView.reactPreferredFocusedView = viewToFocus;
18621861
[rootView setNeedsFocusUpdate];
18631862
[rootView updateFocusIfNeeded];
1863+
#else
1864+
[viewToFocus becomeFirstResponder];
18641865
#endif
18651866
}
18661867

0 commit comments

Comments
 (0)