diff --git a/packages/examples/pages/text-input/index.js b/packages/examples/pages/text-input/index.js index 48da3d3b..54f93abe 100644 --- a/packages/examples/pages/text-input/index.js +++ b/packages/examples/pages/text-input/index.js @@ -14,6 +14,13 @@ export default function TextInputPage() { return ( + { + console.log('focused'); + }} + style={styles.textinput} + /> focusNextField()} diff --git a/packages/react-native-web/src/exports/TextInput/__tests__/index-test.js b/packages/react-native-web/src/exports/TextInput/__tests__/index-test.js index 19357b54..5a798667 100644 --- a/packages/react-native-web/src/exports/TextInput/__tests__/index-test.js +++ b/packages/react-native-web/src/exports/TextInput/__tests__/index-test.js @@ -95,7 +95,7 @@ describe('components/TextInput', () => { }); test('value "true"', () => { - const { container } = render(); + const { container } = render(); const input = findInput(container); expect(document.activeElement).toBe(input); }); diff --git a/packages/react-native-web/src/exports/TextInput/index.js b/packages/react-native-web/src/exports/TextInput/index.js index ef3cb270..965dc45a 100644 --- a/packages/react-native-web/src/exports/TextInput/index.js +++ b/packages/react-native-web/src/exports/TextInput/index.js @@ -229,12 +229,12 @@ const TextInput: React.AbstractComponent< function handleFocus(e) { const node = hostRef.current; + if (onFocus) { + e.nativeEvent.text = e.target.value; + onFocus(e); + } if (node != null) { TextInputState._currentlyFocusedNode = node; - if (onFocus) { - e.nativeEvent.text = e.target.value; - onFocus(e); - } if (clearTextOnFocus) { node.value = ''; }