Skip to content

Commit 879af06

Browse files
authored
always expand the omnibar when top of the page is reached (#5968)
Task/Issue URL: https://app.asana.com/1/137249556945/project/1208671518894266/task/1210004588627880?focus=true ### Description Fixes an issue with the omnibar not showing up when scrolling up by ensuring we always expand it when top of the page is reached. Details in the task. ### Steps to test this PR - [ ] Play around with the omnibar and ensure that it's always shown when top of the page is reached, even when it's via a fling gesture. - [ ] Try bottom omnibar too. You can also try scrolling up slowly and check for any jitter - should be none. However, if you creep up very very slowly to the top of the page, without flinging and without allowing the omnibar to expand, it won't automatically expand to prevent it being misinterpreted as a gesture in the opposite direction and causing unintended content shift.
1 parent cba05cd commit 879af06

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

app/src/main/java/com/duckduckgo/app/browser/BrowserTabFragment.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ class BrowserTabFragment :
623623
get() = activity as? BrowserActivity
624624

625625
private var webView: DuckDuckGoWebView? = null
626+
private var isWebViewGestureInProgress = false
626627

627628
private val tabSwitcherActivityResult = registerForActivityResult(StartActivityForResult()) { result ->
628629
if (result.resultCode == RESULT_OK) {
@@ -2853,12 +2854,30 @@ class BrowserTabFragment :
28532854
}
28542855

28552856
it.setOnTouchListener { webView, event ->
2857+
when (event.actionMasked) {
2858+
MotionEvent.ACTION_DOWN -> {
2859+
isWebViewGestureInProgress = true
2860+
}
2861+
2862+
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
2863+
isWebViewGestureInProgress = false
2864+
}
2865+
}
2866+
28562867
if (omnibar.omnibarTextInput.isFocused) {
28572868
binding.focusDummy.requestFocus()
28582869
}
28592870
dismissAppLinkSnackBar()
28602871
false
28612872
}
2873+
it.setOnScrollChangeListener { v, _, _, _, _ ->
2874+
if (!v.canScrollVertically(-1) && !isWebViewGestureInProgress) {
2875+
// Automatically expand the omnibar when the web view is at the top, but only if the user isn't actively scrolling.
2876+
// Expanding the omnibar changes the web view's offset, which could otherwise be misinterpreted by the framework
2877+
// as a fling gesture in the opposite direction and cause unintended content shifting.
2878+
omnibar.setExpanded(true)
2879+
}
2880+
}
28622881

28632882
it.setEnableSwipeRefreshCallback { enable ->
28642883
binding.swipeRefreshContainer?.isEnabled = enable

0 commit comments

Comments
 (0)