Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fabric, text input): use window to focus and blur TextInput #2284

Merged
merged 3 commits into from
Nov 20, 2024

Conversation

Saadnajmi
Copy link
Collaborator

@Saadnajmi Saadnajmi commented Nov 15, 2024

Summary:

Cherry pick a couple of changes to have TextInput call focus and blur (natively, makeFirstResponder and resignFirstResponder) through its window instance variable rather than through its' self.

Test Plan:

RNTester runs fine while focusing and blurring some text inputs.

@Saadnajmi Saadnajmi force-pushed the fabric/text-input branch 3 times, most recently from 1b0cfcf to 081ac2a Compare November 19, 2024 22:09
@Saadnajmi Saadnajmi changed the title fix(fabric): Cherrry-pick fixes to TextInput fix(fabric): Cherry-pick fixes to TextInput Nov 19, 2024
@Saadnajmi Saadnajmi changed the title fix(fabric): Cherry-pick fixes to TextInput fix(fabric): Cherry-pick fixes to render Text in an NSTextView Nov 20, 2024
@Saadnajmi Saadnajmi changed the title fix(fabric): Cherry-pick fixes to render Text in an NSTextView [DRAFT][WIP] fix(fabric): Cherry-pick fixes Nov 20, 2024
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
@Saadnajmi Saadnajmi marked this pull request as ready for review November 20, 2024 00:47
@Saadnajmi Saadnajmi requested a review from a team as a code owner November 20, 2024 00:47
@Saadnajmi Saadnajmi changed the title [DRAFT][WIP] fix(fabric): Cherry-pick fixes fix(fabric, text input): use window to focus and blur TextInput Nov 20, 2024
…stance

Summary:
Fix AppKit exception throws when blurring text inputs by calling `resignFirstResponder` directly on the backing text input view.
Resigning the first responder state has to happen through the window by calling `[window makeFirstResponder:nil]` which will:
- call `resignFirstResponder` on the current first responder
- if successful, the window will become the first responder

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 and the blur on the search field
- The focused field resigns the first responder status without throwing an exception

 https://pxl.cl/3GvZD

Reviewers: shawndempsey, #rn-desktop

Reviewed By: shawndempsey

Differential Revision: https://phabricator.intern.facebook.com/D50700782
@Saadnajmi Saadnajmi merged commit 8d07d9c into microsoft:main Nov 20, 2024
14 checks passed
@Saadnajmi Saadnajmi deleted the fabric/text-input branch November 20, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants