Skip to content

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

Merged
Saad Najmi (Saadnajmi) merged 3 commits into
microsoft:mainfrom
Saadnajmi:fabric/text-input
Nov 20, 2024
Merged

fix(fabric, text input): use window to focus and blur TextInput#2284
Saad Najmi (Saadnajmi) merged 3 commits into
microsoft:mainfrom
Saadnajmi:fabric/text-input

Conversation

@Saadnajmi

@SaadnajmiSaad Najmi (Saadnajmi) commented Nov 15, 2024

Copy link
Copy Markdown
Collaborator

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
Saad Najmi (Saadnajmi)force-pushed the fabric/text-input branch 3 times, most recently from 1b0cfcf to 081ac2aCompareNovember 19, 2024 22:09
@SaadnajmiSaad Najmi (Saadnajmi) changed the title fix(fabric): Cherrry-pick fixes to TextInputfix(fabric): Cherry-pick fixes to TextInputNov 19, 2024
@SaadnajmiSaad Najmi (Saadnajmi) changed the title fix(fabric): Cherry-pick fixes to TextInputfix(fabric): Cherry-pick fixes to render Text in an NSTextViewNov 20, 2024
@SaadnajmiSaad Najmi (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
Saad Najmi (Saadnajmi) marked this pull request as ready for review November 20, 2024 00:47
@Saadnajmi
Saad Najmi (Saadnajmi) requested a review from a team as a code ownerNovember 20, 2024 00:47
@SaadnajmiSaad Najmi (Saadnajmi) changed the title [DRAFT][WIP] fix(fabric): Cherry-pick fixes fix(fabric, text input): use window to focus and blur TextInputNov 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
Saad Najmi (Saadnajmi) merged commit 8d07d9c into microsoft:mainNov 20, 2024
@Saadnajmi
Saad Najmi (Saadnajmi) deleted the fabric/text-input branch November 20, 2024 18:27
Sign up for freeto 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

@Saadnajmi@lenaic@tido64@FalseLobster@PPatBoyd