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.

Android - TextInput Autofill not working

See original GitHub issue

“react-native”: “0.61.4” "react-native-screens: “2.0.0-alpha.5”

It seems that the library blocks the native autofill suggestions view. Also, there is no save password dialog after a successful login. (This dialog is auto popped-up by the Android framework).

<TextInput
              placeholder={'Username'}
              autoCompleteType={'email'}
 />
  <TextInput
              placeholder={'Password'}
              autoCompleteType={'password'}
              secureTextEntry={true}
/> 

Setting those props should be enough to trigger the autofill mechanism.

What we tried and did not work:

  • Update to a library version after the PR from #205 was merged.
  • Set the TextInput width to 99% on first render and then to 100%, as suggested
  • Set the TextInput editable prop to false on first render and then on true, as suggested

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:19
  • Comments:38 (13 by maintainers)

github_iconTop GitHub Comments

14reactions
foloinfocommented, Jun 8, 2021

I had the same issue on Android devices and accidentaly realized that it works as expected when I use state to mount the TextInput right after mouting the screen component.

example:


const Screen = ()=> {

  const [shown, setShown] = useState(false)
  useEffect(()=> {
    setShown(true)
  }, [])

  return (
    <View>
      {shown ? (
        <>
          <TextInput
             autoCompleteType='email'
             importantForAutofill='yes'
             //...rest
           />
           <TextInput
             autoCompleteType='password'
             importantForAutofill='yes'
             secureTextEntry={true}
             //...rest
           />
         <>
       ) : null}
    </View>
  )

}

I’m using "react-native-screens": "~3.0.0" and react-navigation v5 with expo sdk 41 (React Native 0.63). Also I have called enableScreen(true) and the TextInput is inside the ScrollView.

I have no idea why it solves the issue but at least it’s working for me right now. I hope this helps on the other versions.

5reactions
aperomingocommented, Oct 30, 2020

I have suffered a lot to implement this in iOS successfully:

  • Create account (password suggestion and later saved in the KeyChain)
  • Login (choice of username and password of your KeyChain).

However, in Android there is little information and I think that it is not very successful:

  • The information about the React Native TextInput only tells you to implement the property autoCompleteType = {'password'} and importantForAutofill = {'yes' }.
  • Then on the other hand, on Android https://developer.android.com/guide/topics/text/autofill-services they tell you about “Permissions and manifest declarations” .
  • Also, this collides with react-native-screens and its enableScreens method, which has not worked for me with either true or false.

I don’t know what to do, these kinds of problems that always happen with React Native make me desperate. Normally you have more problems and it is more complicated with iOS, but in this case I think not, in my case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optimize your app for autofill - Android Developers
The autofill framework saves user input for future use by showing a "Save for autofill?" dialog after the autofill context is finished.
Read more >
android - EditText AutoCorrect and AutoComplete not working
I was having some problems with auto-correction and it seems that textAutoComplete means that the input will be automatically completed ...
Read more >
react-native-autocomplete-input - npm
Start using react-native-autocomplete-input in your project by running `npm i react-native-autocomplete-input`. There are 13 other projects ...
Read more >
Cant turn off autocomplete in Textinput (Android) : r/reactnative
When user tries to log in into his account, if the email is typed manually, the authentication works with no problem. Also, if...
Read more >
Working with the EditText | CodePath Android Cliffnotes
Working with the EditText. Edit PagePage History. Overview. The EditText is the standard text entry widget in Android apps. If the user needs...
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