-
Notifications
You must be signed in to change notification settings - Fork 24.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TextInput] Auto correction doesn't call onChangeText after submit #2552
Comments
@dsibiski - ping |
Catches a spelling auto correction when the 'Return' key is pressed and makes sure that a `RCTTextEventTypeChange` event fires. - Doesn't increment the `nativeEventCount` as it doesn't need to match up with JS. - Extracts a few methods in `RCTTextFieldManager` to reduce duplication introduced. Resolves: facebook#2552
@michalraska There is my attempt at solving this issue. 😄 I was hoping the fix would be simpler, let's hope the core team likes the solution. |
Hi, |
Catches a spelling auto correction when the 'Return' key is pressed and makes sure that a `RCTTextEventTypeChange` event fires. - Doesn't increment the `nativeEventCount` as it doesn't need to match up with JS. - Extracts a few methods in `RCTTextFieldManager` to reduce duplication introduced. Resolves: facebook#2552
+1 |
+1 |
1 similar comment
+1 |
+1 |
+1 |
+1. Any news? If commit fixes things, can we get this merged soon? |
This is being addressed by #9852, which has not yet landed. |
Any updates on merging #9852? |
@shergin RN 0.42 [iOS] - |
@grundmanise That's sad. :( |
@shergin Haven't you got any issues with |
Any update on this? |
I'm seeing this as well on 0.44.0. |
+1 |
+1 0.45.1 |
+1 This issue also affect Chinese input which use same technology with autocorrect. And there may be more foreign keyboards are broken. Please help us ASAP. My current workaround is to only take values when blur. Thanks. |
Hi there! This issue is being closed because it has been inactive for a while. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. Either way, we're automatically closing issues after a period of inactivity. Please do not take it personally! If you think this issue should definitely remain open, please let us know. The following information is helpful when it comes to determining if the issue should be re-opened:
If you would like to work on a patch to fix the issue, contributions are very welcome! Read through the contribution guide, and feel free to hop into #react-native if you need help planning your contribution. |
Just tested it with version 0.48 and this bug still exists. It is a very serious bug and should be resolved. |
@rohitgoyal, I agree. Your best bet at this point is to open a new issue, and link to this one. Commenting on the closed one won't get any attention. |
The issue is real and we still have to fix this. |
@rohitgoyal Do you have an example that reproduces this? I just attempted to reproduce this on 0.48.4 but couldn't. We're currently using 0.41.2 and encountered this bug. Planning to upgrade versions and hoping that it'll solve this, but it appears it isn't fixed yet? @shergin is there an estimate on when this might be fixed? |
In the meantime, I thought of a workaround that seems to work (but please let me know if there's a flaw). Basically, in your onChangeTextCallback = (text) => { /* do stuff */ }
onSubmitEditingCallback = (e) => { /* do stuff */ } <TextInput
onChangeText = {onChangeTextCallback}
onSubmitEditing = {(e) => {
onChangeTextCallback(e.nativeEvent.text);
onSubmitEditingCallback(e);
}}
/> |
@kevin91liu I'm trying your solution now and it doesn't seem to fix the problem. |
Got a code snippet to share @Is0metry ? It worked for me, but I didn't test it thoroughly. |
@kevin91liu onChangeTextCallback = (event) => {
this.setState({
['text']:event
});
}
onSubmitEditingCallback = (event)=> {
const todos = this.state.todos.slice().concat([{key:this.state.text}]);
this.setState({
todos:todos,
text:'',
});
} and my text box rendering: return(
//rendering of FlatList
<NewTodo style={styles.input} value={this.state.text} onSubmitEditing={(e) => {
this.onChangeTextCallback(e.nativeEvent.text);
this.onSubmitEditingCallback(e);
}} onChangeText={this.onChangeTextCallback}/>
</View>
); NewTodo basically just a |
@Is0metry I think you meant to say that NewTodo is a wrapper for a I think I know what the problem is. React's setState is asynchronous, so when you call So what I think is happening in your example is:
For your case, I'd suggest trying the following and see if it fixes things: return(
//rendering of FlatList
<NewTodo
style={styles.input}
value={this.state.text}
onSubmitEditing={(e) => {
this.setState({
text: e.nativeEvent.text
}, () => {
this.onSubmitEditingCallback(e);
});
}}
onChangeText={this.onChangeTextCallback}
/>
</View>
); |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
I believe it should remain open because it can result in users entering in different text than they believe. |
This appears to be fixed in v0.54.0: ⚡️ |
I'm using 0.54.2 and issue continues @hramos . lastNativeText, nativeEvent.text, this.state.text doesn't update with autocorrect. onChange and onChangeText doesn't fire |
and confirmed this bug exists in 0.55.2 as well |
This is pretty annoying, especially in e2e testing this can confuse a lot. |
Hey folks, this issue is closed as fixed. I highly recommend opening a new issue instead of commenting on here, since we'd like to see why your particular use case is not resolved. |
Hi,
when I write to TextInupt some typo, e.g. "awrsome" and tap submit, in text input is displayed awesome but this change doesn't call method set to property onChangeText.
The text was updated successfully, but these errors were encountered: