Skip to content

Commit 2b7bbcf

Browse files
committed
style(fabric, textinput): dont' nil check the window before calling focus / blur
1 parent edbec15 commit 2b7bbcf

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -531,10 +531,8 @@ - (void)focus
531531
#if !TARGET_OS_OSX // [macOS]
532532
[_backedTextInputView becomeFirstResponder];
533533
#else // [macOS
534-
NSWindow *window = _backedTextInputView.window;
535-
if (window) {
536-
[window makeFirstResponder:_backedTextInputView];
537-
}
534+
NSWindow *window = [_backedTextInputView window];
535+
[window makeFirstResponder:_backedTextInputView];
538536
#endif // macOS]
539537

540538
const auto &props = static_cast<const TextInputProps &>(*_props);
@@ -555,12 +553,9 @@ - (void)blur
555553
#if !TARGET_OS_OSX // [macOS]
556554
[_backedTextInputView resignFirstResponder];
557555
#else // [macOS
558-
NSWindow *window = _backedTextInputView.window;
559-
if (window && window.firstResponder == _backedTextInputView) {
560-
// Calling makeFirstResponder with nil will call resignFirstResponder and make the window the first responder
561-
[window makeFirstResponder:nil];
562-
}
563-
#endif // macOS];
556+
NSWindow *window = [_backedTextInputView window];
557+
[window makeFirstResponder:nil];
558+
#endif // macOS]
564559
}
565560

566561
- (void)setTextAndSelection:(NSInteger)eventCount

0 commit comments

Comments
 (0)