Skip to content

TextInput's caret always move to beginning when toggling secureTextEntry #18377

@williamliangwl

Description

@williamliangwl

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>
    );
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: TextInputRelated to the TextInput component.Ran CommandsOne of our bots successfully processed a command.StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions