Skip to content

Commit 5f3faf6

Browse files
shwantonSaadnajmi
authored andcommitted
[fabric] TextInput should get focus with autoFocus prop
Summary: **Context** - TextInput focus prop was not wired up for Fabric **Change** - Focus the text input if `autofocus={true}` Test Plan: Tested in top of stack Reviewers: lefever, #rn-desktop Reviewed By: lefever Differential Revision: https://phabricator.intern.facebook.com/D54880714
1 parent 3275685 commit 5f3faf6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,12 @@ - (void)didMoveToWindow
142142
if (props.autoFocus) {
143143
#if !TARGET_OS_OSX // [macOS]
144144
[_backedTextInputView becomeFirstResponder];
145-
#endif // [macOS]
145+
#else // [macOS
146+
NSWindow *window = [_backedTextInputView window];
147+
if (window) {
148+
[window makeFirstResponder:_backedTextInputView.responder];
149+
}
150+
#endif // macOS]
146151
[self scrollCursorIntoView];
147152
}
148153
_didMoveToWindow = YES;

0 commit comments

Comments
 (0)