2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-17 15:26:23 +00:00

[fenix] Close https://github.com/mozilla-mobile/fenix/issues/20701: Dismiss keyboard when scrolling home screen

This commit is contained in:
Roger Yang 2021-12-01 15:22:24 -05:00 committed by mergify[bot]
parent a39062eb9b
commit 9534fa2356
2 changed files with 9 additions and 19 deletions

View File

@ -877,20 +877,6 @@ class HomeFragment : Fragment() {
} }
private fun navigateToSearch() { private fun navigateToSearch() {
// Dismisses the search dialog when the home content is scrolled
val recyclerView = sessionControlView!!.view
val listener = object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
if (newState == RecyclerView.SCROLL_STATE_DRAGGING || newState == RecyclerView.SCROLL_STATE_SETTLING) {
findNavController().navigateUp()
recyclerView.removeOnScrollListener(this)
}
}
}
recyclerView.addOnScrollListener(listener)
val directions = val directions =
HomeFragmentDirections.actionGlobalSearchDialog( HomeFragmentDirections.actionGlobalSearchDialog(
sessionId = null sessionId = null

View File

@ -246,12 +246,16 @@ class SearchDialogFragment : AppCompatDialogFragment(), UserInteractionHandler {
setupConstraints(view) setupConstraints(view)
// When displayed above browser, dismisses dialog on clicking scrim area // When displayed above browser or home screen, dismisses keyboard when touching scrim area
if (findNavController().previousBackStackEntry?.destination?.id == R.id.browserFragment) { when (findNavController().previousBackStackEntry?.destination?.id) {
binding.searchWrapper.setOnClickListener { R.id.browserFragment, R.id.homeFragment -> {
it.hideKeyboard() binding.searchWrapper.setOnTouchListener { _, _ ->
dismissAllowingStateLoss() binding.searchWrapper.hideKeyboard()
toolbarView.view.clearFocus()
false
}
} }
else -> {}
} }
binding.searchEnginesShortcutButton.setOnClickListener { binding.searchEnginesShortcutButton.setOnClickListener {