Skip to content

fix: RCTViewComponentView can become first responder only when enableImperativeFocus flag is enabled#55908

Draft
war-in wants to merge 1 commit intofacebook:mainfrom
war-in:war-in/fix-focus-RN-83
Draft

fix: RCTViewComponentView can become first responder only when enableImperativeFocus flag is enabled#55908
war-in wants to merge 1 commit intofacebook:mainfrom
war-in:war-in/fix-focus-RN-83

Conversation

@war-in
Copy link
Contributor

@war-in war-in commented Mar 4, 2026

Summary:

In RN 0.83, RCTViewComponentView.canBecomeFirstResponder was changed to unconditionally return YES as part of the enableImperativeFocus feature. This causes UIKit to promote parent views to first responder after navigation transitions complete (via _promoteSelfOrDescendantToFirstResponderIfNecessary), stealing focus from text inputs and triggering an immediate focus→blur cycle.

This fix gates canBecomeFirstResponder behind the enableImperativeFocus feature flag (which defaults to false), so views only become eligible for first responder when imperative focus is actually enabled.

Changelog:

[IOS] [FIXED] - Fixed RCTViewComponentView unconditionally returning YES from canBecomeFirstResponder, which caused focus to be stolen from text inputs after navigation transitions

Test Plan:

  1. Create a screen with a TextInput that receives focus on mount (e.g. via autoFocus or a useEffect calling .focus()).
  2. Navigate to that screen using a navigation library (e.g. React Navigation).
  3. Verify the TextInput retains focus and the keyboard stays visible after the transition completes — previously the input would briefly gain then lose focus (focus→blur cycle).

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Mar 4, 2026
@war-in
Copy link
Contributor Author

war-in commented Mar 4, 2026

cc @sbuggay as you were implementing the original PR. Please, let me know if that change makes sense 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant