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

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

For https://github.com/mozilla-mobile/fenix/issues/26790 -  recent tab
This commit is contained in:
Alexandru2909 2022-09-06 09:38:57 +03:00 committed by mergify[bot]
parent bcc8d09c2c
commit 3d949c808f
7 changed files with 47 additions and 1 deletions

View File

@ -29,6 +29,11 @@ interface RecentTabController {
*/
fun handleRecentTabClicked(tabId: String)
/**
* @see [RecentTabInteractor.onRecentTabLongClicked]
*/
fun handleRecentTabLongClicked()
/**
* @see [RecentTabInteractor.onRecentTabShowAllClicked]
*/
@ -64,6 +69,10 @@ class DefaultRecentTabsController(
navController.navigate(R.id.browserFragment)
}
override fun handleRecentTabLongClicked() {
dismissSearchDialogIfDisplayed()
}
override fun handleRecentTabShowAllClicked() {
dismissSearchDialogIfDisplayed()
RecentTabs.showAllClicked.record(NoExtras())

View File

@ -17,6 +17,11 @@ interface RecentTabInteractor {
*/
fun onRecentTabClicked(tabId: String)
/**
* Called when the user long clicks on a recent tab.
*/
fun onRecentTabLongClicked()
/**
* Show the tabs tray. Called when a user clicks on the "Show all" button besides the recent
* tabs.

View File

@ -46,6 +46,7 @@ class RecentTabViewHolder(
RecentTabs(
recentTabs = recentTabs.value ?: emptyList(),
onRecentTabClick = { recentTabInteractor.onRecentTabClicked(it) },
onRecentTabLongClick = { recentTabInteractor.onRecentTabLongClicked() },
menuItems = listOf(
RecentTabMenuItem(
title = stringResource(id = R.string.recent_tab_menu_item_remove),

View File

@ -72,6 +72,7 @@ fun RecentTabs(
recentTabs: List<RecentTab>,
menuItems: List<RecentTabMenuItem>,
onRecentTabClick: (String) -> Unit = {},
onRecentTabLongClick: () -> Unit = {},
) {
Column(
modifier = Modifier.fillMaxWidth(),
@ -84,6 +85,7 @@ fun RecentTabs(
tab = tab,
menuItems = menuItems,
onRecentTabClick = onRecentTabClick,
onRecentTabLongClick = onRecentTabLongClick,
)
}
}
@ -103,6 +105,7 @@ private fun RecentTabItem(
tab: RecentTab.Tab,
menuItems: List<RecentTabMenuItem>,
onRecentTabClick: (String) -> Unit = {},
onRecentTabLongClick: () -> Unit = {},
) {
var isMenuExpanded by remember { mutableStateOf(false) }
@ -113,7 +116,10 @@ private fun RecentTabItem(
.combinedClickable(
enabled = true,
onClick = { onRecentTabClick(tab.state.id) },
onLongClick = { isMenuExpanded = true },
onLongClick = {
onRecentTabLongClick()
isMenuExpanded = true
},
),
shape = RoundedCornerShape(8.dp),
backgroundColor = FirefoxTheme.colors.layer2,

View File

@ -380,6 +380,10 @@ class SessionControlInteractor(
recentTabController.handleRecentTabShowAllClicked()
}
override fun onRecentTabLongClicked() {
recentTabController.handleRecentTabLongClicked()
}
override fun onRemoveRecentTab(tab: RecentTab.Tab) {
recentTabController.handleRecentTabRemoved(tab)
}

View File

@ -162,6 +162,12 @@ class SessionControlInteractorTest {
verify { recentTabController.handleRecentTabClicked(tabId) }
}
@Test
fun onRecentTabLongClicked() {
interactor.onRecentTabLongClicked()
verify { recentTabController.handleRecentTabLongClicked() }
}
@Test
fun onRecentTabShowAllClicked() {
interactor.onRecentTabShowAllClicked()

View File

@ -163,4 +163,19 @@ class RecentTabControllerTest {
assertNotNull(RecentTabs.showAllClicked.testGetValue())
}
@Test
fun `GIVEN search dialog is displayed WHEN long clicking a recent tab THEN search dialog is dismissed`() {
every { navController.currentDestination } returns mockk {
every { id } returns R.id.searchDialogFragment
}
every { navController.navigateUp() } returns true
controller.handleRecentTabLongClicked()
verify {
controller.dismissSearchDialogIfDisplayed()
navController.navigateUp()
}
}
}