Skip to content

Commit 0195640

Browse files
authored
Pressing back after dismissing keyboard in find in page close find in page view (#797)
* Fixed backButton behavior when findInPage is active * Added test for backButton behavior when findInPage is active
1 parent 1122e17 commit 0195640

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

app/src/androidTest/java/com/duckduckgo/app/browser/BrowserTabViewModelTest.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,19 @@ class BrowserTabViewModelTest {
872872
assertTrue(browserViewState().canGoForward)
873873
}
874874

875+
@Test
876+
fun whenFindInPageShowingByPressingBackOnBrowserThenViewStateUpdatedInvisibleAndDoesNotGoToPreviousPage() {
877+
setupNavigation(isBrowsing = true, canGoBack = true)
878+
testee.onFindInPageSelected()
879+
testee.onUserPressedBack()
880+
881+
assertFalse(findInPageViewState().visible)
882+
assertCommandIssued<Command.DismissFindInPage>()
883+
884+
val issuedCommand = commandCaptor.allValues.find { it is Command.NavigateBack }
885+
assertNull(issuedCommand)
886+
}
887+
875888
@Test
876889
fun whenHomeShowingByPressingBackOnInvalidatedBrowserThenForwardButtonInactive() {
877890
setupNavigation(isBrowsing = true)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,11 @@ class BrowserTabViewModel(
415415
fun onUserPressedBack(): Boolean {
416416
val navigation = webNavigationState ?: return false
417417

418+
if (currentFindInPageViewState().visible) {
419+
dismissFindInView()
420+
return true
421+
}
422+
418423
if (!currentBrowserViewState().browserShowing) {
419424
return false
420425
}

0 commit comments

Comments
 (0)