Skip to content
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

[Android] [TextInput] selection property has no effect #22513

Closed
3 tasks done
jamsch opened this issue Dec 4, 2018 · 4 comments
Closed
3 tasks done

[Android] [TextInput] selection property has no effect #22513

jamsch opened this issue Dec 4, 2018 · 4 comments
Labels
Bug Component: Text Component: TextInput Related to the TextInput component. Platform: Android Android applications. Platform: Linux Building on Linux. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@jamsch
Copy link
Contributor

jamsch commented Dec 4, 2018

Environment

Run react-native info in your terminal and paste its contents here.

  React Native Environment Info:
    System:
      OS: Linux 4.15 Ubuntu 18.04.1 LTS (Bionic Beaver)
      CPU: x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
      Memory: 1.12 GB / 15.54 GB
      Shell: 4.4.19 - /bin/bash
    Binaries:
      Node: 10.9.0 - ~/.nvm/versions/node/v10.9.0/bin/node
      Yarn: 1.10.1 - /usr/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v10.9.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      Android SDK:
        Build Tools: 23.0.1, 23.0.2, 23.0.3, 25.0.0, 25.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 27.0.0, 27.0.1, 27.0.3
        API Levels: 23, 24, 25, 26, 27
    npmPackages:
      @storybook/react-native: 4.0.11 => 4.0.11
      @types/react: ^16.7.13 => 16.7.13
      @types/react-native: ^0.57.17 => 0.57.17
      react: ^16.6.3 => 16.6.3
      react-native: 0.57.7 => 0.57.7

Description

So I have this TextInput component that's supposed to toggle between secureTextEntry, a common use case for showing/hiding password. The issue is that the text selection is reset to the start of the input and I can't find a way to set the cursor position to the end after toggling "show/hide password".

In other words, setting the property selection={{ start: number, end: number }} on a TextInput element seems to do nothing.

What's been attempted:

  1. Setting the selection state after a button click event.
  2. Updating selection state after the onSelectionChange event
  3. Using textInputRef.current.setNativeProps({ selection: {} }) on componentDidUpdate

Image:

peek 2018-12-05 11-40

Reproducible Demo

https://snack.expo.io/HkvTKtEkN

@react-native-bot react-native-bot added 🔶Components Component: Text Component: TextInput Related to the TextInput component. Platform: Android Android applications. Platform: Linux Building on Linux. labels Dec 5, 2018
@farshidshahmoradi1996
Copy link

dear @jamsch ,if you can't resolve this problem don't worry,
you can blur Input Component after changing secureTextEntry when you blur component user should click on input Component again and therefor user decide where set cursor.

@bobsmits
Copy link

bobsmits commented Apr 10, 2019

We have the exactly the same issue. Also with an password show / hide. If anyone has a solution i would be grateful.

@stale
Copy link

stale bot commented Aug 2, 2019

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as a "Discussion" or add it to the "Backlog" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 2, 2019
@stale
Copy link

stale bot commented Aug 9, 2019

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.

@stale stale bot closed this as completed Aug 9, 2019
@facebook facebook locked as resolved and limited conversation to collaborators Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Component: Text Component: TextInput Related to the TextInput component. Platform: Android Android applications. Platform: Linux Building on Linux. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

5 participants