GlobalSearchController: Auto focus search view when initial query is empty (#8073)

(cherry picked from commit 0fabe4bd013a1980b0fa3e70306e851acd1b5bc3)
This commit is contained in:
Ivan Iskandar 2022-09-25 19:53:34 +07:00 committed by Jobobby04
parent fc8b15916a
commit 0d0513cff7

View File

@ -101,6 +101,20 @@ open class GlobalSearchController(
)
optionsMenuSearchItem = menu.findItem(R.id.action_search)
// Focus search on launch from browse screen
if (initialQuery.isNullOrEmpty()) {
optionsMenuSearchItem?.expandActionView()
}
}
override fun onSearchMenuItemActionCollapse(item: MenuItem?) {
super.onSearchMenuItemActionCollapse(item)
// Close this screen if query is empty
// i.e. launch from browse screen and clicking the back button icon without making any search
if (presenter.query.isEmpty()) {
router.popCurrentController()
}
}
override fun onSearchMenuItemActionExpand(item: MenuItem?) {