TextInput's caret always move to beginning when toggling secureTextEntry
See original GitHub issueI am using ReactNative v.0.52.0 and currently developing a TextInput for password, but want to enable user to show / hide their typed input. The problem when toggling the value of secureTextEntry, the caret always move to the beginning of the input.
I have only tested this in Android device.
Environment
Environment:
- OS: Windows 10
- Node: 6.11.5
- Yarn: 1.3.2
- npm: 4.6.1
- Watchman: Not Found
- Xcode: N/A
- Android Studio: Version 3.0.0.0 AI-171.4443003
Packages: (wanted => installed)
- react: 16.2.0 => 16.2.0
- react-native: 0.52.0 => 0.52.0
Expected Behavior
I expect the caret will always stay at the end of the input, when toggling the secureTextEntry
Steps to Reproduce
I manage to reproduce this using a very simple code, I put it at the App.js
export default class App extends Component {
constructor() {
super();
this.state = {
showPassword: false
};
}
toggleShow() {
this.setState({
showPassword: !this.state.showPassword
});
}
render() {
return (
<View>
<TextInput secureTextEntry={this.state.showPassword} />
<Button title={'Toggle'} onPress={this.toggleShow.bind(this)} />
</View>
);
}
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:12 (1 by maintainers)
Top Results From Across the Web
TextInput cursor move to the beginning on reveal/hide password
I'm having a problem with TextInput cursor when reveal or hide password value, when the user touch the reveal password button the cursor...
Read more >TextInput SecureTextEntry toggle resets cursor position - Reddit
When this secureTextEntry is toggled with setState the cursor resets to position 0 (beginning of text) instead of the end, ...
Read more >TextInput - React Native
A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, ...
Read more >React: handling an input caret position | by Alberto De Natale
When we modify the text of an HTML input while the user types using React, we may see the caret jumping at the...
Read more >Embed a secure text entry toggle button into a UITextField | by ...
Beginner iOS Dev. Image from https://www.cyclonis.com. Like most of my articles — the above is something I've had to do for an app...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@react-native-bot Yes tested in v0.54.2 and still having same issue in Android device
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.