From 2b7bbcfd99a2bc070a1b0e1e06b1aad32755c336 Mon Sep 17 00:00:00 2001 From: Saad Najmi Date: Wed, 20 Nov 2024 09:17:02 -0800 Subject: [PATCH] style(fabric, textinput): dont' nil check the window before calling focus / blur --- .../TextInput/RCTTextInputComponentView.mm | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) 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 4aafb8c88cb954..4b282fb0b99b69 100644 --- a/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +++ b/packages/react-native/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm @@ -531,10 +531,8 @@ - (void)focus #if !TARGET_OS_OSX // [macOS] [_backedTextInputView becomeFirstResponder]; #else // [macOS - NSWindow *window = _backedTextInputView.window; - if (window) { - [window makeFirstResponder:_backedTextInputView]; - } + NSWindow *window = [_backedTextInputView window]; + [window makeFirstResponder:_backedTextInputView]; #endif // macOS] const auto &props = static_cast(*_props); @@ -555,12 +553,9 @@ - (void)blur #if !TARGET_OS_OSX // [macOS] [_backedTextInputView resignFirstResponder]; #else // [macOS - NSWindow *window = _backedTextInputView.window; - if (window && window.firstResponder == _backedTextInputView) { - // Calling makeFirstResponder with nil will call resignFirstResponder and make the window the first responder - [window makeFirstResponder:nil]; - } -#endif // macOS]; + NSWindow *window = [_backedTextInputView window]; + [window makeFirstResponder:nil]; +#endif // macOS] } - (void)setTextAndSelection:(NSInteger)eventCount