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: secureTextEntry toggle causes keyboard change; keyboard does not automatically come up #27946

Open
mjfiandaca opened this issue Feb 4, 2020 · 31 comments
Labels
Component: TextInput Related to the TextInput component. Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Needs: React Native Team Attention Platform: Android Android applications. Platform: iOS iOS applications.

Comments

@mjfiandaca
Copy link

Description:
When enabling the user to toggle the secure text entry flag on a text input, on Android, two issues are occurring:

  1. The keyboard does not automatically come up when rendering; the user must tap on the field.
  2. Tapping the 'eye' icon to toggle the secureTextEntry flag from false to true switches the keyboard type.

React Native version:

System:    OS: Windows 10 10.0.17134
    CPU: (4) ia32 Intel(R) Pentium(R) CPU G4560T @ 2.90GHz
    Memory: 1.65 GB / 7.43 GB
  Binaries:
    Node: 12.10.0 - C:\Program Files (x86)\nodejs\node.EXE
    Yarn: 1.10.1 - C:\Users\mjfiandaca\AppData\Roaming\npm\yarn.CMD
    npm: 6.13.4 - C:\Program Files (x86)\nodejs\npm.CMD
  SDKs:
    Android SDK:
      API Levels: 23, 25, 26, 27, 28
      Build Tools: 23.0.1, 25.0.1, 26.0.3, 27.0.3, 28.0.0, 28.0.3
      System Images: android-23 | Intel x86 Atom, android-23 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom_64, android-26 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom_64, android-27 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom_64, android-28 | Google Play Intel x86 Atom
  IDEs:
    Android Studio: Version  3.5.0.0 AI-191.8026.42.35.6010548
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.6 => 0.60.6

Steps To Reproduce

  1. Sign onto the provided snack.
  2. Intermittently, the keyboard will not come up (I tested this several times; sometimes, no keyboard, sometimes, app starts, flashes, and then the keyboard comes up).
  3. Tap on the 'eye' icon to toggle the secure text entry.
  4. Notice the keyboard changes.

Expected Results

The keyboard should not change based on the secure text entry value.

Snack, code example, screenshot, or link to a repository:

https://snack.expo.io/@mjfiandaca/toggle-securetextentry

@mjfiandaca
Copy link
Author

Update this so it does not go stale. This is still an issue.

@chrisglein
Copy link

Sounds like you're still hitting this. Is this true on latest version? (60 is a couple versions behind now)

@github-actions
Copy link

⚠️ Using Old Version
ℹ️ It looks like you are using an older version of React Native. Please upgrade to the latest version, and verify if the issue persists. If it does not, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the current release.

@mjfiandaca
Copy link
Author

I can still reproduce this on the expo snack I referenced above, which is using expo v36.0.0.
According to this webpage https://docs.expo.io/versions/latest/#each-expo-sdk-version-depends-on-a that expo version is using rn 0.61.4.

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Apr 29, 2020
@mjfiandaca
Copy link
Author

And my own app is now at 0.62.0, and it is still an issue there as well.

@stale
Copy link

stale bot commented Jul 29, 2020

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 Jul 29, 2020
@mjfiandaca
Copy link
Author

Not stale.
My app was just updated to react 0.63.2.
The issue remains.

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Aug 5, 2020
@chrisglein
Copy link

Confirmed repro on provided Snack.

Android

Launch Press TextInput Toggle Eye
image image image

iOS

Launch Press TextInput Toggle Eye
image image image

@chrisglein chrisglein added Component: TextInput Related to the TextInput component. Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Platform: Android Android applications. and removed Needs: Attention Issues where the author has responded to feedback. Newer Patch Available labels Aug 5, 2020
@dutradotdev
Copy link

same here

@gregwm
Copy link

gregwm commented Sep 4, 2020

Any update on this? If you change keyboardType on Android you have to re-focus the text-input for the keyboard to come back up. This is a pain for things like toggling secureTextEntry.

@mjfiandaca
Copy link
Author

A few updates on this item.

  1. I traced this back (I believe) to the code in ReactTextinputManager.java (node_modules -> react-native -> ReactAndroid -> src -> main -> java -> com -> facebook -> react -> views -> textinput).

When the prop secureTextEntry is true, the code sets the input type to InputType.TYPE_NUMBER_VARIATION_PASSWORD (versus keeping the input type a number).

@ReactProp(name = "secureTextEntry", defaultBoolean = false)
public void setSceureTextEntry(ReactEditText view, boolean password) {
updateStatedInputTypeFlag(
view,
password ? 0
: InputType.TYPE_NUMBER_VARIATION_PASSWORD | InputType.TYPE_TEXT_VARIATION_PASSWORD,
password ? InputType.TYPE_TEXT_VARIATION_PASSWORD : 0);
checkPasswordType(view);

Then within check password type, it will switch it to the numbered type with the password variant.

I am having trouble finding documentation on the android developer site which actually shows the different keyboards (with a picture!), but here is the android doc:
https://developer.android.com/reference/android/text/InputType#TYPE_NUMBER_VARIATION_PASSWORD

So, this seems to be working as it is coded; but the question remains....should it be switching the type if the intended keyboard type was number, to include password variants, or should it just keep the keyboard the same in the case of numeric types?

An alternate would be, if there is a possibility of toggling the secure text entry flag, then the keyboard which appears when secureTextEntry is true should be available as a keyboard type in react native.

  1. With RN v. 0.63.2, the keyboard is coming up appropriately when autofocus is true so for my part, that issue was resolved.

  2. Someone marked this as an iOS issue as well; it is only android.

@Jeffreyoboe1
Copy link

Not stale, needing resolution.

@mistricky
Copy link

Same problem, any workaround here?

@anilrai01
Copy link

Yeah not stale, it still need fixes on Android

@matheusnrc
Copy link

In version 0.63.4 the issue still remains

@anilrai01
Copy link

I think the possible solution would be to let us revert back the Keyboard type from 'visible-password' to the one that is being set when the secureText entry is set to True ( In Android ). The possible workaround was to toggle the boolean value in secureTextEntry with state variable and set the keyboardType to 'visible-password' once the secureTextEntry is set to false but, the password won't revert back to obscured text once the keyboard is set to 'visible-password'.

We need fix on this issue. Or is there any other workaround ? I heard that the facebook app is also build with React Native? But they are doing fine on toggling password visibility in Android. Is there anything that we're missing or still unaware of ?

@fabOnReact
Copy link
Contributor

fabOnReact commented Feb 16, 2021

The minimum reproducable example

class RewriteExample extends React.Component<$FlowFixMeProps, any> {
  constructor(props) {
    super(props);
    this.state = {show: true};
  }
  render() {
    return (
      <>
        <TextInput
          keyboardType={'numeric'}
          secureTextEntry={!this.state.show}
        />
        <Button title="show" onPress={() => this.setState({show: !this.state.show})} />
      </>
    );
  }
}

I was trying to understand which flag is applied and the correlated limitations from the Android API (#26799 (comment))

@hetansh1
Copy link

hetansh1 commented Jul 1, 2021

Still has the, Keyboard change issue on Android,
Please provide Any Working Solution...

@Tesmi
Copy link

Tesmi commented Jul 16, 2021

Please provide the solution or at least a viable workaround.

@josetheis
Copy link

Still an issue.

@CarlessoMauricio
Copy link

same here

@Xtrendence
Copy link

This is indeed still an issue.

@stale
Copy link

stale bot commented Jan 9, 2022

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 Jan 9, 2022
@carissacks
Copy link

any update on this?

@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 13, 2022
@newbanker-damon
Copy link

newbanker-damon commented Jan 21, 2022

I have the some problem

https://snack.expo.dev/@damoness/2df00c

@ITTECH10
Copy link

ITTECH10 commented Apr 13, 2022

Solution is to import Pressable from react-native ... (note: I am using ui kitten library)
const renderIcon = (props) => (
Pressable onPress={toggleSecureEntry}>
<Icon {...props} name={secureTextEntry ? 'eye-off' : 'eye'} />
Pressable
);

@othman95
Copy link

is there an update on this ? did anyone find a way to get the same numbers keyboard type that's used when secure text entry flag is set to true on android ?

@Osmon11
Copy link

Osmon11 commented Aug 7, 2023

the same issue

@pfndesign
Copy link

0.72.5 . same issue here.

@degeloper34
Copy link

0.72.4, same issue here.

@salman0ansari
Copy link

there is no fix to solve this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: TextInput Related to the TextInput component. Issue: Author Provided Repro This issue can be reproduced in Snack or an attached project. Needs: React Native Team Attention Platform: Android Android applications. Platform: iOS iOS applications.
Projects
None yet
Development

No branches or pull requests