mikepenz/MaterialDrawer

Soft input (keyboard) remains open on navigation

Sternbach-Software opened this issue · 7 comments

About this issue

  • If the user had the soft input (keyboard) opened and was typing something when they decided to navigate away, the keyboard does not close and they are navigated to a screen where there is no e.g. EditText and the keyboard should not be opened. I am using the Navigation component. A solution would be to allow passing in a lambda for onSuccessfulNavigation to MaterialDrawerSliderView.setupWithNavController() instead of just a fallBackListener

Details

  •  Used library version: 8.4.0
  •  Used support library version
  •  Used gradle build tools version
  •  Used tooling / Android Studio version
  •  Other used libraries, potential conflicting libraries

Checklist

Thank you for the report @shmueldabomb441

Wouldn't a normal listener on the DrawerLayout (e.g. after the layout is closed) also serve the same functionality?
Also I wonder, why did you not close the keyboard when the DrawerLayout was opened already?

Because when setting it up with the navigation component, the onclick listener is set to deal with the navigation, so setting it myself would be counter productive. It is a single listener, not an array of listeners.

Also, it isn't certain that the user will navigate just when the open the drawer. They could be checking the email in the header or something.

I'd argue that the common approach is to close the keyboard when opening the drawerLayout: https://developer.android.com/reference/androidx/drawerlayout/widget/DrawerLayout.DrawerListener

Will need to think more about adding another listener

How would you do it like you're saying while allowing it to set up the listener for the Navigation component? I can hear where you are coming from, because the keyboard may block the user from one of the list items, in which case they will close it themselves anyway, so the app might as well do it for them.

Decided to get this listener added, dropped a commit though as it contained unused code, and added backwards compatiblity.

This will land in v9