<TextInput
ref={inputRef}
value={text}
style={styles.textInput}
returnKeyType="next"
placeholder={'placeholder'}
scrollEnabled={false}
blurOnSubmit={false}
onFocus={onFocusInput}
textAlignVertical="center"
onContentSizeChange={onChangeContentSizeChange}
onChangeText={onInputChangeValue}
onBlur={onInputBlur}
onKeyPress={onInputKeyPress}
onSubmitEditing={() =>NextScript(id)}
multiline={false}
numberOfLines={5}
/>
The logic is i want onSubmitEditing to take me to next textinputfield and i need the text to wrap one much text is entered. If i enable multiline once enterkey is pressed it goes to next line before going to the next input and that’s what i am trying to avoud
Is it possible to replace enter key totally with onSubmitEditing? anytime i hit enter it attempts to enter newlinw before moving to next TextInput, so it creates a bad UI where the text is moving up slightly before repositioning then going to next line
If i set bluronSubmit to true, it stops but keyboard closes on submit.
If i set multiline to false it stops but doesnt wrap text.
2
Answers
I have created an example,
onKeyPress
will allow you to focus the next textfield when enter key were hit.I’m also facing the same issues. Later, I found the solution.
Custom Text Input Handling: You’ll need a custom logic to handle the text input and its behavior upon pressing the ‘Enter’ key. Instead of relying on the default behavior of multiline, you’ll control the text wrapping and navigation to the next input field programmatically.
Replace Enter Key with onSubmitEditing: To override the default behavior of the ‘Enter’ key, you can use the onKeyPress event. Detect when the ‘Enter’ key is pressed and programmatically trigger the onSubmitEditing function.
Maintain Text Wrapping: Since multiline={false} disables automatic text wrapping, you’ll need to implement a method to manually handle text wrapping based on the input’s content size or character count.
Here’s a conceptual example of how you might implement this: