Typing in a TextInput with option { secureTextEntry: true } should consistently show the last typed character until the next character input.
After the first typed character, the last typed character is shown but disappears almost instantly.
Only seen in Android. iOS is OK
This only happens when setting the value property on the TextInput – letting the TextInput handle this on its own won't break the functionality.
// Broken
<TextInput
placeholder="Password"
secureTextEntry={true}
value={this.state.password1}
onChangeText={(password1) => this.setState({ password1 })}
/>
// Works
<TextInput
placeholder="Password"
secureTextEntry={true}
onChangeText={(password2) => this.setState({ password2 })}
/>
A hacky workaround for this is to avoid setState in onChangeText and use class properties instead:
class MyComponent extends Component {
props: {
onSubmit: (password: string) => void
}
render() {
return (
<View>
<TextInput
placeholder="Password"
secureTextEntry={true}
onChangeText={(password) => this.password = password}
/>
<Button
onPress={() => {this.props.onSubmit(this.password)}}
title="Submit"
/>
</View>
);
}
}
This avoids rerendering the screen on each text change and thus circumvents the described issue.
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.
@hramos I'm not really sure if I'm missing something but isn't Canny for feature requests? This is clearly a bug, in my opinion.
Any way I can help with this? Its a _really_ annoying issue…
I created a Snack demo of this in the meantime: https://snack.expo.io/SJ5HkmJLb
I agree, we should keep stale issues out of Canny. Edited my message.
I would like this to be fixed too.
Anyway for now, is anythig wrong with @Strayer approach by not setting value={this.state.password1}? how does it change the behavior of application? From my own tests it seems everything works the same if I set the value property or not. The only thing I can think of is if I want to set the value prior to user editing it, which is not such a big problem with password during login, if i don't store it anywhere.
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.
This issue is not resolved yet. Could you reopen this? In addition, is there any update on this?
It doesn't seem like anyone worked on a solution. If this is affecting you, consider opening a new issue with more information about your specific situation.
yes I agree this issue has not been resolved I am using version 0.48 and samsung s6 android 7.0
I am on 0.49.5, still occurs on Android 7.x.x and Android 8.x.x
It is exactly as @Strayer described in his example.
I am also still having this issue on Android 6.x.x
The first character works as expected, it starting from the second character that it isn't working any more.
To make this worse: type in a second character, then delete that second character, now the first character becomes visible.
I also have this problem with Android Xiaomi Mi6. Why is this issue still closed if there are so many people having the same problem?
@hramos: can you take a look at this? I'm also experiencing this exactly same thing on Android 7.x.x.
still an issue in 0.51.0
This is happening for me in IOs RN: 0.48.4
This is an issue in iOS and Android for RN 0.55. Just upgraded to find this problem. Not setting a value on an input doesn't seem like a proper solution, and–at least with iOS–this is a regression.
Most helpful comment
I am also still having this issue on Android 6.x.x
The first character works as expected, it starting from the second character that it isn't working any more.
To make this worse: type in a second character, then delete that second character, now the first character becomes visible.