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 Keyboard Handling

See original GitHub issue

Bug

Keyboard handling with Android is a nightmare, so @gorhom I’m grateful for your patience and hard work on this.

Here is a clean example that will highlight the different bugs I am facing. Please check each point using an iPhone and an Android device to compare.

If I find new bugs, I will update this issue. Also, when you introduce a new fix, we can use this issue to make sure the bugs are resolved and test to see no other exist.

Everyone else is welcome to comment. If you can suggest a new way to produce a bug with clean code, please share and I will update the snack to demonstrate.

Environment info

I’m using alpha 12 because I cannot use the https://github.com/gorhom/react-native-bottom-sheet/tree/fix/489-improve-keyboard-handling fix on snack. If something has already been resolved by the fix, please let me know. Also, alpha 13 has a bug https://github.com/gorhom/react-native-bottom-sheet/issues/507 that needs to be resolved.

Library Version
@gorhom/bottom-sheet 4.0.0-alpha.12

Steps To Reproduce

Android Specific

Snap points are set on iOS but not Android

When clicking inside the TextInput, the BottomSheet expands. Check the console log and click inside the TextInput

  • iOS: it updates the BS snap point.
  • Android: not updating snap point.

Because searchSheet hasn’t snapped to point 2, as it does on iOS, resultsCarouselRef.current?.close(); never fires so the resultsCarousel sheet never closes.

Another consequence of the same issue:

Drag searchSheet to the middle snap point. resultsCarousel will hide. Now click inside the TextInput. searchSheet will expand but not update the snap point on Android. Then manually drag the sheet to the bottom. resultsCarousel will not restore because it doesn’t know anything changed.

BottomSheet gets stuck

Click inside the TextInput, the BottomSheet will expand. Submit on the keyboard and SearchHandle will setRunningSearch(true), which will kick off a useEffect on App.tsx that will collapse the BottomSheet.

Try to drag the BottomSheet up. It will snap back to the bottom. Again, because it never updated the snap points.

BottomSheet stops responding

Click inside the TextInput, the BottomSheet will expand. Submit on the keyboard and SearchHandle will setRunningSearch(true), which will kick off a useEffect on App.tsx that will collapse the BottomSheet.

  • Drag the Results BottomSheet down. Search BottomSheet will expand.
  • Drag the Search BottomSheet down. Results BottomSheet will not expand as expected.

Both Android and iOS

  1. Drag down the resultsCarousel and before it closes, click inside the TextInput. Search BottomSheet will not expand to the top as expected.
  2. Drag down resultsCarousel. Search BottomSheet will start expanding. While it’s expanding, drag it down. resultsCarousel will not expand as expected

Reproducible sample code

https://snack.expo.io/@kickbk/android-keyboard-handling

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:27 (10 by maintainers)

github_iconTop GitHub Comments

5reactions
KingAmocommented, Sep 18, 2021

is it possible to disable keyboard handling ? i think we should provide a props enableKeyboardHandling @gorhom any help please?

1reaction
moyolveracommented, Jul 1, 2021

@kickbk can you check again? i did forgot to click on the save button

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handle keyboard input - Android Developers
The Android system shows an on-screen keyboard—known as a soft input method—when a text field in your UI receives focus. To provide the...
Read more >
Working with the Soft Keyboard | CodePath Android Cliffnotes
The Android system shows an on-screen keyboard, known as a soft input method, when a text field in your UI receives focus. To...
Read more >
Handling Keyboard Actions | Android Developers
To handle an individual key press, implement onKeyDown() or onKeyUp() as appropriate. Usually, you should use onKeyUp() if you want to be sure...
Read more >
Virtual keyboard - Processing for Android
The virtual or soft keyboard on an Android device needs to be opened and closed with the openKeyboard() and closeKeyboard() functions. Once the...
Read more >
Keyboard Handling on Android - PSPDFKit
// Threshold for minimal keyboard height. final int MIN_KEYBOARD_HEIGHT_PX = 150; // Top-level window decor view. final View decorView = activity ...
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