Skip to content

TextInput doesn't lose focus after dismissing keyboard on some Android devices #33532

Open

Description

@Ol1va

Description

Current Behavior

When TextInput is focused and keyboard is shown, pressing hardware back button dismisses the keyboard but doesnt't blur the TextInput. Pressing on the TextInput again doesn't trigger the keyboard.

I noticed it happening on these devices: Mobistart V1 (android v 9), Meizu M3s (android v 5.1), Honor 8 (android v 7).
This behaviour doesn't seem to be dependant on Android version or brand.
Also this behaviour appears in every React Native app.

Expected Behavior

The TextInput should lose focus after hardware back button press.

2022-03-31.17.43.12.mp4

Version

0.65.1

Output of npx react-native info

No warnings or errors apper in console.

Steps to reproduce

Basically it happens with any TextInput.

<TextInput />

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

No response

Activity

  1. chrisbobbe commented on Mar 31, 2022

    @chrisbobbe

    Probably related (the issue is closed but still reproduces): #19366

  2. Ol1va commented on Apr 1, 2022

    @Ol1va
    Author

    Unfortunately that solution doesn't work for me, because it suggests to make a handler for each TextInput in every React Naive project.

  3. chrisbobbe commented on Apr 1, 2022

    @chrisbobbe

    Hmm, yeah, that's unfortunate. I'm hoping the link might be helpful for you or anyone else who has time to dig into React Native's internals to find the bug and propose a fix. I'll post here if I manage to do that too. 🙂

  4. ghiculescualexandru commented on Apr 20, 2022

    @ghiculescualexandru

    Any updates on this?

  5. Ol1va commented on Apr 20, 2022

    @Ol1va
    Author

    Any updates on this?

    Unfortunately, no

  6. ghiculescualexandru commented on Apr 20, 2022

    @ghiculescualexandru

    Any updates on this?

    Unfortunately, no

    I managed to work around by adding a ref to the text input and a keyboard listener to blur the text input when the keyboard hide.
    Here is the logic:

      const localInputRef = useRef<TextInput>();
      
      const keyboardDidHideCallback = () => {
         localInputRef.current.blur?.();   
      }
    
      useEffect(() => {
         const keyboardDidHideSubscription = Keyboard.addListener('keyboardDidHide', keyboardDidHideCallback);
    
         return () => {
          keyboardDidHideSubscription?.remove();
        };
      }, []);
    
     <TextInput
           ref={(ref) => {
              localInputRef && (localInputRef.current = ref as any);
           }}
     .....
     </TextInput>
    
  7. sankparatkar commented on May 6, 2022

    @sankparatkar

    @ghiculescualexandru you did this for every TextInput box?

  8. ghiculescualexandru commented on May 9, 2022

    @ghiculescualexandru

    Only needed it in a single place, however, you can create a component with this behaviour and use it everywhere

  9. github-actions commented on Nov 6, 2022

    @github-actions

    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.

  10. added
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Nov 6, 2022
  11. jludwiggreenaction commented on Nov 18, 2022

    @jludwiggreenaction

    This is still an issue on react native v0.69.6, unsure if fixed in .7

  12. 10 remaining items

  13. Rc85 commented on Nov 18, 2024

    @Rc85

    The only workaround is pressing the send/enter button the keyboard while the text input is focused. But if you have onSubmitEditing to submit a form or something, then this is not ideal.

  14. ashfaqdevdksa commented on Dec 6, 2024

    @ashfaqdevdksa

    @cipolleschi @cortinico Please fix this.

  15. muhammadashfaq commented on Dec 9, 2024

    @muhammadashfaq

    May be it can help someone 🚀🚀🚀

    I was able to fix it with following workaround. This perfectly loses focus after user leaves the input doesn't matter clicking any where from example from bottom back button from android etc.

    Don't forget to import Keyboard from react-native 😉😉😉

      useEffect(() => {
        const hideSubscription = Keyboard.addListener('keyboardDidHide', () => {
          Keyboard.dismiss();
        });
        return () => {
          hideSubscription.remove();
        };
      }, []);
    
  16. cipolleschi commented on Dec 17, 2024

    @cipolleschi
    Contributor

    I just test this in a recent version (0.77.0-rc.3 and 0.76.5) of React Native and it seems to work fine.
    I can:

    • focus on the Text Field, the keyboard appear.
    • press the back button, the keyboard disappear, the text field remains focused.
    • tapping on the Text Field again make the keyboard appear again.\
    0.77.0-rc.3 0.76.5

    I think this has been fixed. Can someone else test this out?

  17. samcodefish commented on Feb 12, 2025

    @samcodefish

    I just test this in a recent version (0.77.0-rc.3 and 0.76.5) of React Native and it seems to work fine. I can:

    • focus on the Text Field, the keyboard appear.
    • press the back button, the keyboard disappear, the text field remains focused.
    • tapping on the Text Field again make the keyboard appear again.\

    I think this has been fixed. Can someone else test this out?

    Hi @cipolleschi , I think maybe you have misunderstood the issue?

    The problem is that the TextInput remains focussed when the keyboard is dismissed. Which your demo illustrates.

    The desired behaviour would be for the TextInput to become unfocussed when the keyboard is dismissed with the back button press.

  18. alanggdev commented on May 13, 2025

    @alanggdev

    Any updates on this?

  19. sayan-avantai commented on Jun 9, 2025

    @sayan-avantai

    any update on this?

  20. jdziadek commented on Jul 8, 2025

    @jdziadek

    Bump

  21. Bowuigi commented on Oct 8, 2025

    @Bowuigi

    Can reproduce in RN 0.81.4, Expo 54.0.12, Android 11. Every workaround mentioned (here and in #19366, namely, blur-then-focus and Keyboard.dismiss()) works though.

  22. ramchandra-st commented on Feb 10, 2026

    @ramchandra-st

    Bump

  23. BejPastan commented on May 22, 2026

    @BejPastan

    Still doesn't work

  24. react-native-bot commented on Nov 19, 2026

    @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 Nov 19, 2026
  26. jwallet commented on Nov 19, 2026

    @jwallet

    So this bug will stay then

  27. removed
    StaleThere has been a lack of activity on this issue and it may be closed soon.
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions