Skip to content

Commit 8819d6c

Browse files
authored
fix: TextInputFocus state not in sync with View focus (#2553)
## Summary: This is fixed upstream with facebook#52472 . Let's commit (and backport) a smaller fix for now. ## Test Plan: Minimal repro of bug is this code below. Basically, you can't focus on "Pressable Child 2" twice by clicking on the container ``` <Pressable style={{backgroundColor: 'lightblue', padding: 10, gap: 10}} onPress={() => {myRef.current.focus();}}> <Text>Pressable Container</Text> <Pressable><Text>Pressable Child 1</Text></Pressable> <Pressable ref={myRef}><Text>Pressable Child 2</Text></Pressable> <Pressable><Text>Pressable Child 3</Text></Pressable> </Pressable> ```
1 parent 02d5480 commit 8819d6c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/react-native/Libraries/Components/TextInput/TextInputState.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ function focusTextInput(textField: ?HostInstance) {
103103

104104
if (textField != null) {
105105
const fieldCanBeFocused =
106-
currentlyFocusedInputRef !== textField &&
106+
// [macOS currentlyFocusedInputRef does not account for the fact that any arbritrary view can
107+
// recieve focus on desktop. https://github.com/facebook/react-native/pull/52472/ fixes this,
108+
// disable the check for now
109+
// currentlyFocusedInputRef !== textField &&
110+
// macOS]
107111
// $FlowFixMe - `currentProps` is missing in `NativeMethods`
108112
textField.currentProps?.editable !== false;
109113

0 commit comments

Comments
 (0)