[fix] TextInput calls onFocus if autoFocus={true}

The host node ref is not a dependency of the focus handling. Previously, the
focus callback was not called if the element was auto-focused, because  React
DOM calls `onFocus` while the object ref is `null`.

Fix #2045
This commit is contained in:
Nicolas Gallagher
2021-06-08 15:58:16 -07:00
parent 3fc7634819
commit 697479e2cd
3 changed files with 12 additions and 5 deletions
@@ -14,6 +14,13 @@ export default function TextInputPage() {
return (
<Example title="TextInput">
<View style={styles.container}>
<TextInput
autoFocus
onFocus={() => {
console.log('focused');
}}
style={styles.textinput}
/>
<TextInput
blurOnSubmit={true}
onSubmitEditing={() => focusNextField()}