diff --git a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm index 876344c26054bd..83cfeb779dfc8e 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -528,7 +528,12 @@ - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args - (void)focus { +#if !TARGET_OS_OSX // [macOS] [_backedTextInputView becomeFirstResponder]; +#else // [macOS + NSWindow *window = [_backedTextInputView window]; + [window makeFirstResponder:_backedTextInputView]; +#endif // macOS] const auto &props = static_cast(*_props); @@ -545,7 +550,14 @@ - (void)focus - (void)blur { +#if !TARGET_OS_OSX // [macOS] [_backedTextInputView resignFirstResponder]; +#else // [macOS + NSWindow *window = [_backedTextInputView window]; + if ([window firstResponder] == _backedTextInputView) { + [window makeFirstResponder:nil]; + } +#endif // macOS] } - (void)setTextAndSelection:(NSInteger)eventCount