Skip to content

Commit

Permalink
[fabric] Make text input first responder through the window instance
Browse files Browse the repository at this point in the history
Summary:
Fix AppKit exception throws when focusing text inputs by calling becomeFirstResponder directly on the backing text input view.

Making a view first responder has to happen through the window using makeFirstResponder.

Test Plan:
- Run Zeratul with Fabric
- Focus the search text input above the message threads
- Click inside the active message thread to trigger the auto-focus of the composer
- The composer gets focus without AppKit throwing an exception.

 https://pxl.cl/3dVMx

Reviewers: shawndempsey, #rn-desktop

Reviewed By: shawndempsey

Differential Revision: https://phabricator.intern.facebook.com/D48696690
  • Loading branch information
Nick Lefever authored and Saadnajmi committed Nov 20, 2024
1 parent 9d326ef commit 81527c1
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,14 @@ - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args

- (void)focus
{
#if !TARGET_OS_OSX // [macOS]
[_backedTextInputView becomeFirstResponder];
#else // [macOS
NSWindow *window = _backedTextInputView.window;
if (window) {
[window makeFirstResponder:_backedTextInputView];
}
#endif // macOS]

const auto &props = static_cast<const TextInputProps &>(*_props);

Expand Down

0 comments on commit 81527c1

Please sign in to comment.