question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TextInput's caret always move to beginning when toggling secureTextEntry

See original GitHub issue

I 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:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
williamliangwlcommented, Mar 16, 2018

@react-native-bot Yes tested in v0.54.2 and still having same issue in Android device

0reactions
stale[bot]commented, Dec 28, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found