[fenix] For https://github.com/mozilla-mobile/fenix/issues/26690 - Dismiss search dialog when opening recent synced tab dropdown menu

pull/600/head
Alexandru2909 2 years ago committed by mergify[bot]
parent 632a03ff12
commit 5202efa275

@ -25,6 +25,11 @@ interface RecentSyncedTabController {
*/
fun handleRecentSyncedTabClick(tab: RecentSyncedTab)
/**
* @see [RecentSyncedTabInteractor.onRecentSyncedTabLongClick]
*/
fun handleRecentSyncedTabLongClick()
/**
* @see [RecentSyncedTabInteractor.onRecentSyncedTabClicked]
*/
@ -66,6 +71,12 @@ class DefaultRecentSyncedTabController(
)
}
override fun handleRecentSyncedTabLongClick() {
if (navController.currentDestination?.id == R.id.searchDialogFragment) {
navController.navigateUp()
}
}
override fun handleRecentSyncedTabRemoved(tab: RecentSyncedTab) {
appStore.dispatch(AppAction.RemoveRecentSyncedTab(tab))
}

@ -17,6 +17,11 @@ interface RecentSyncedTabInteractor {
*/
fun onRecentSyncedTabClicked(tab: RecentSyncedTab)
/**
* Called when opening the dropdown menu on a recent synced tab by long press.
*/
fun onRecentSyncedTabLongClick()
/**
* Opens the tabs tray to the synced tab page. Called when a user clicks on the "See all synced
* tabs" button.

@ -59,6 +59,7 @@ import org.mozilla.fenix.theme.Theme
* @param onRecentSyncedTabClick Invoked when the user clicks on the recent synced tab.
* @param onSeeAllSyncedTabsButtonClick Invoked when user clicks on the "See all" button in the synced tab card.
* @param onRemoveSyncedTab Invoked when user clicks on the "Remove" dropdown menu option.
* @param onRecentSyncedTabLongClick Invoked when user long presses the recent synced tab.
*/
@OptIn(ExperimentalFoundationApi::class)
@Suppress("LongMethod")
@ -68,6 +69,7 @@ fun RecentSyncedTab(
onRecentSyncedTabClick: (RecentSyncedTab) -> Unit,
onSeeAllSyncedTabsButtonClick: () -> Unit,
onRemoveSyncedTab: (RecentSyncedTab) -> Unit,
onRecentSyncedTabLongClick: () -> Unit,
) {
var isDropdownExpanded by remember { mutableStateOf(false) }
@ -82,7 +84,10 @@ fun RecentSyncedTab(
.height(180.dp)
.combinedClickable(
onClick = { tab?.let { onRecentSyncedTabClick(tab) } },
onLongClick = { isDropdownExpanded = true },
onLongClick = {
onRecentSyncedTabLongClick()
isDropdownExpanded = true
},
),
shape = RoundedCornerShape(8.dp),
backgroundColor = FirefoxTheme.colors.layer2,
@ -285,6 +290,7 @@ private fun LoadedRecentSyncedTab() {
onRecentSyncedTabClick = {},
onSeeAllSyncedTabsButtonClick = {},
onRemoveSyncedTab = {},
onRecentSyncedTabLongClick = {},
)
}
}
@ -298,6 +304,7 @@ private fun LoadingRecentSyncedTab() {
onRecentSyncedTabClick = {},
onSeeAllSyncedTabsButtonClick = {},
onRemoveSyncedTab = {},
onRecentSyncedTabLongClick = {},
)
}
}

@ -56,6 +56,7 @@ class RecentSyncedTabViewHolder(
onRecentSyncedTabClick = recentSyncedTabInteractor::onRecentSyncedTabClicked,
onSeeAllSyncedTabsButtonClick = recentSyncedTabInteractor::onSyncedTabShowAllClicked,
onRemoveSyncedTab = recentSyncedTabInteractor::onRemovedRecentSyncedTab,
onRecentSyncedTabLongClick = recentSyncedTabInteractor::onRecentSyncedTabLongClick,
)
}
}

@ -392,6 +392,10 @@ class SessionControlInteractor(
recentSyncedTabController.handleRecentSyncedTabClick(tab)
}
override fun onRecentSyncedTabLongClick() {
recentSyncedTabController.handleRecentSyncedTabLongClick()
}
override fun onSyncedTabShowAllClicked() {
recentSyncedTabController.handleSyncedTabShowAllClicked()
}

@ -150,6 +150,20 @@ class DefaultRecentSyncedTabControllerTest {
}
}
@Test
fun `GIVEN search dialog is displayed WHEN recent synced tab is long clicked THEN dismiss search dialog`() {
every { navController.navigateUp() } returns true
every { navController.currentDestination } returns mockk {
every { id } returns R.id.searchDialogFragment
}
controller.handleRecentSyncedTabLongClick()
verify {
navController.navigateUp()
}
}
@Test
fun `WHEN synced tab clicked THEN metric counter labeled by device type is incremented`() {
val url = "https://mozilla.org"

Loading…
Cancel
Save