Skip to content

Commit

Permalink
style(fabric, textinput): don't nil check the window before calling f…
Browse files Browse the repository at this point in the history
…ocus / blur
  • Loading branch information
Saadnajmi committed Nov 20, 2024
1 parent edbec15 commit 78467d2
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<const TextInputProps &>(*_props);
Expand All @@ -555,12 +553,11 @@ - (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
NSWindow *window = [_backedTextInputView window];
if ([window firstResponder] == _backedTextInputView) {
[window makeFirstResponder:nil];
}
#endif // macOS];
#endif // macOS]
}

- (void)setTextAndSelection:(NSInteger)eventCount
Expand Down

0 comments on commit 78467d2

Please sign in to comment.