Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix TextInput focus when inside a FocusZone (#3849)
* Fix TextInput focus when inside a FocusZone When a TextInput is not inside a FocusZone, it properly participates in the key view loop in that Tab\Shift+Tab will place focus on the inner `RCTUITextView`, instead of the outer `RCTBaseTextInputView` subclass. This is due to [overriding](https://github.com/microsoft/react-native-macos/blob/b7033b3513d98b20a08ec20abfe2b9bb712c68d4/packages/react-native/Libraries/Text/TextInput/RCTBaseTextInputView.mm#L1147C1-L1150C2) the `canBecomeKeyView` in that base class. However, the FocusZone control does not look at that property -- instead it only considers `canBecomeFirstResponder`, as seen in #2329. Although it seems like the logical next step to use `canBecomeKeyView` in the FocusZone, that was previously done with #2267 but later reverted in #2322 since it broke things downstream. Instead, we'll make a compromise and leak some of the text input implementation details into the focus zone -- if we're considering focusing a subclass of `RCTBaseTextInputView`, we'll instead use the containing `backedTextInputView`. Testing: * TI inside FZ is now properly focused (using the new case added to the FZ page) * Verified all other cases on the FZ page * Verified in the downstream scenario that prompted this investigation Notes: * I noticed that Shift+Ctrl+Tab does not move focus out of the containing FZ, but that has been determined to be a pre-existing issue, and thus isn't being addressed in this change.
- Loading branch information