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

Fix keyboard not hiding on RN 62+ #592

Merged
merged 1 commit into from Aug 6, 2020
Merged

Conversation

kmagiera
Copy link
Member

@kmagiera kmagiera commented Aug 6, 2020

This PR fixes the problem with Android's soft keyboard staying open when going away from a screen with the focused text input.

The fix is to force keyboard to hide when the screen is detached.

Testing

The issue could've been reproduced on RN 62 on NativeStack example in the repo, but was only apparent on Android 5, while we haven't figured out a consistent way to reproduce on modern version of Android (we know the new versions were also intermittently affected). Repro steps:

  1. Go to NativeStack example app on Android
  2. Touch text field and see soft keyboard opens
  3. Click "PUSH" button to navigate to the next screen – the keyboard would stay open despite the text field from the previous screen is gone

With this change in, the keybord is closed upon navigating away from the screen with the focused field.

@kmagiera kmagiera requested a review from WoLewicki August 6, 2020 13:49
@kmagiera kmagiera merged commit 49561e7 into master Aug 6, 2020
@kmagiera kmagiera deleted the android-keyboard-issue branch August 6, 2020 14:01
kmagiera added a commit that referenced this pull request Aug 17, 2020
…#603)

This is a follow up fix after #592 where we attempted to fix the issue while introducing a regression in the way autoFocus is handled. That is, in case there was a text field with an auto focus in the next screen, the logic we added for screen dismissal would cause it to immediately lose focus.

This fix moves the logic responsible for keyboard force-dismiss to execute earlier – at the moment when we attempt to detach the previous screen. This way we can still rely on the focused child property to point to a correct children. Note that before, detaching a view would result in the child losing focus but the keyboard would stay open. We now use this fact and can verify that the focused children is the one being removed, and only in that case we ask system to hide the keyboard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants