Skip to content

TextInput closes automatically when opened on android #33164

Closed as not planned
Closed as not planned

Description

@Cristi6

Description

Hi there,

I switched laptops and cloned the repository of my project, did a quick yarn install and looks like it was a big difference from the one on the main branch but I didn't bother since maybe it's just because of different Node versions.

Now every time I click on one TextInput the keyboard opens and closes immediately only on android. I attached a quick recording here. Tried some solutions and it looks like switching android:windowSoftInputMode from adjustResize to adjustPan in AndroidManifest.xml fixes the problem with the closing but I'm not really happy with the behaviour of the keyboard in the app when it's set to adjustPan.

Version

0.64.0

Output of npx react-native info

System:
    OS: macOS 11.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 29.16 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
  Binaries:
    Node: 16.5.0 - ~/.nvm/versions/node/v16.5.0/bin/node
    Yarn: 1.22.15 - ~/.yarn/bin/yarn
    npm: 7.19.1 - ~/.nvm/versions/node/v16.5.0/bin/npm
    Watchman: 2021.06.07.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK:
      API Levels: 29, 30, 31
      Build Tools: 29.0.2, 29.0.3, 31.0.0
      System Images: android-29 | Google APIs Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.2 AI-202.7660.26.42.7486908
    Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_292 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1 
    react-native: 0.64.0 => 0.64.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

Not really sure what could be the steps to reproduce. Maybe this issue starting happening a while ago but I just saw it now.

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

Here is just an input centered inside a simple View.
https://gfycat.com/ordinaryquestionabledinosaur

Activity

  1. pROFESOR11 commented on Mar 5, 2022

    @pROFESOR11

    Same here, I can confirm that on ios it works fine, but on android we have the same problem.

  2. MohammedWaheeb commented on Mar 5, 2022

    @MohammedWaheeb

    Same here, I can confirm that on ios it works fine, but on android we have the same problem.

    same here

  3. jake-ruth commented on Mar 6, 2022

    @jake-ruth

    Having the same issue on Android

  4. Cristi6 commented on Mar 7, 2022

    @Cristi6
    Author

    Hey all, asked the same thing on StackOverflow and the answer I accepted solved my issue. See if it fixes your problem too.

    https://stackoverflow.com/questions/71227463/react-native-textinput-closes-automatically-when-opened-on-android

  5. maXXCZ1 commented on Mar 7, 2022

    @maXXCZ1

    Hey all, asked the same thing on StackOverflow and the answer I accepted solved my issue. See if it fixes your problem too.

    https://stackoverflow.com/questions/71227463/react-native-textinput-closes-automatically-when-opened-on-android

    Sadly, for me it had no impact, i am still facing same issue.

  6. jake-ruth commented on Mar 7, 2022

    @jake-ruth

    Hey all, asked the same thing on StackOverflow and the answer I accepted solved my issue. See if it fixes your problem too.

    https://stackoverflow.com/questions/71227463/react-native-textinput-closes-automatically-when-opened-on-android

    Appears to be working for me, thanks!

  7. hafizMDM commented on Mar 8, 2022

    @hafizMDM

    Hey all, asked the same thing on StackOverflow and the answer I accepted solved my issue. See if it fixes your problem too.

    https://stackoverflow.com/questions/71227463/react-native-textinput-closes-automatically-when-opened-on-android

    It is working now. Thanks

  8. hafizMDM commented on Mar 8, 2022

    @hafizMDM

    Hey all, asked the same thing on StackOverflow and the answer I accepted solved my issue. See if it fixes your problem too.
    https://stackoverflow.com/questions/71227463/react-native-textinput-closes-automatically-when-opened-on-android

    Sadly, for me it had no impact, i am still facing same issue.

    Try to clean your gradle cache. It was not working for me at first.

  9. maXXCZ1 commented on Mar 8, 2022

    @maXXCZ1

    Hey all, asked the same thing on StackOverflow and the answer I accepted solved my issue. See if it fixes your problem too.
    https://stackoverflow.com/questions/71227463/react-native-textinput-closes-automatically-when-opened-on-android

    Sadly, for me it had no impact, i am still facing same issue.

    Try to clean your gradle cache. It was not working for me at first.

    Thanks, yesterday after clean i managed to run it with 3.4.0 version, today i tried 3.10.2 and it seems to work as well.

  10. kostas2231 commented on Mar 14, 2022

    @kostas2231

    sadly still facing issues with this one , nothing worked for me , what version of native-screens did you exactly used?

  11. santoshsavorbrands commented on Mar 16, 2022

    @santoshsavorbrands

    Unfortunately, none of the above solutions worked for me. Even I've tried multiple versions of react-native-screens, but no luck.

  12. kostas2231 commented on Mar 16, 2022

    @kostas2231

    Unfortunately, none of the above solutions worked for me. Even I've tried multiple versions of react-native-screens, but no luck.

    Finally, made it work the issue I had was that I upgraded to 3.10.2 and not ~3.10.2. Give it a go. Hope this helps.

  13. 23 remaining items

  14. KrisLau commented on Mar 2, 2023

    @KrisLau

    @pandyama AndroidManifest.xml exists in react native projects unless you're using expo.

  15. pandyama commented on Mar 2, 2023

    @pandyama

    @KrisLau sorry ya its an Expo project & i didnt know this, thanks for clarifying!

  16. shubhraagarwal commented on Apr 5, 2023

    @shubhraagarwal

    Hey all, asked the same thing on StackOverflow and the answer I accepted solved my issue. See if it fixes your problem too.

    https://stackoverflow.com/questions/71227463/react-native-textinput-closes-automatically-when-opened-on-android

    the solution provided here is giving me build errors

    image

  17. SaldanhaPrtt commented on Oct 3, 2023

    @SaldanhaPrtt

    Recently encountered this issue and none of the above solutions worked. Was using RN 0.65.3, which is somewhat outdated, upgraded it to 0.66.0 and the problem just went away. Go figure.

  18. Al-Ghozy03 commented on Dec 20, 2023

    @Al-Ghozy03

    i just change from android:windowSoftInputMode="adjustResize"> to android:windowSoftInputMode="adjustPan"> and add react-native-keyboard-aware-scroll-view. if i change android:windowSoftInputMode="stateAlwaysHidden|adjustPan"> the screen can't be scrolled. so i wrap with react-native-keyboard-aware-scroll-view and it works

  19. Al-Ghozy03 commented on Dec 21, 2023

    @Al-Ghozy03

    i just change from android:windowSoftInputMode="adjustResize"> to android:windowSoftInputMode="adjustPan"> and add react-native-keyboard-aware-scroll-view. if i change android:windowSoftInputMode="stateAlwaysHidden|adjustPan"> the screen can't be scrolled. so i wrap with react-native-keyboard-aware-scroll-view and it works

    but the drawback is you have to wrap all of your code using react-native-keyboard-aware-scroll-view if you want your screen can be scrolled when keyboard is active

  20. germanmb23 commented on Apr 21, 2024

    @germanmb23

    I updated react-native from 0.64.3 to 0.66.5 and it worked like a charm. Maybe it also works with some version of 0.65.x
    . I'm also using react react-native-screens.

  21. KrisLau commented on May 15, 2024

    @KrisLau

    @germanmb23 Those versions are really old and you'll likely need to migrate to the 0.70+ versions (current is 0.74 as of writing) to avoid a lot of compatibility issues with other libraries eventually if you're not already encountering them.

  22. mosheFuks commented on Jul 1, 2024

    @mosheFuks

    I'm experiencing the same issue with react-native-screens version 3.30.1. I changed my navigation from Drawer to a combination of Drawer and Stack, and now when I tap on a TextInput, the keyboard appears but disappears after typing a couple of letters. Whatever was supposed to be saved in onChangeText also gets erased because the TextInput reverts back to displaying the placeholder value.

    Any help would be greatly appreciated!

  23. brianlenz commented on Sep 23, 2024

    @brianlenz

    In case this is of use to anyone else:

    We were having the issue with the keyboard disappearing on Android with react-navigation v6 and react-native-screens 3.34.0. We have a KeyboardAvoidingView with a nested <ScrollView keyboardShouldPersistTaps="handled" keyboardDismissMode="on-drag" which contains the TextInput. We use the React Native default android:windowSoftInputMode="adjustResize" in AndroidManifest.xml. The solution for us was to simply omit the behavior attribute in Android from the KeyboardAvoidingView: behavior={Platform.OS === 'android' ? undefined : 'padding'}. With this, the scenarios where we were consistently reproducing the issue no longer had a problem.

    it's unclear from the React Native docs what the default behavior is. Ironically, they recommend you set behavior 🤷‍♂️

    I'll also mention that, for us, the issue was never reproducible 100% of the time on all devices. In fact, the vast majority of users did not have the issue. The issue appeared to only occur when the keyboard was "just the right size" to trigger the problem. As an example, in our testing, it wouldn't happen on standard Samsung Galaxy and Google Pixel setups. If you adjusted the keyboard size and/or the font size, then the issue may present itself.

  24. react-native-bot commented on Mar 23, 2025

    @react-native-bot
    Collaborator

    This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

  25. added
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Mar 23, 2025
  26. react-native-bot commented on Mar 30, 2025

    @react-native-bot
    Collaborator

    This issue was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: TextInputRelated to the TextInput component.Needs: Triage 🔍Platform: AndroidAndroid applications.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