Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,19 @@ actual fun LiquidGlassAppBottomNavigationBar(
currentBackStackEntry?.destination?.let { current ->
Logger.d(TAG, "LiquidGlassAppBottomNavigationBar: current route: ${current.route}")
isInSearchDestination = current.hasRoute(SearchDestination::class)
// Navigation that does not go through selectTab — above all the system Back
// button — changes the destination without touching selectedIndex, so Back from
// Library, Mix or Search landed on Home with the previous tab still highlighted
// (#2714). Sync the highlight from the destination here, where its changes are
// already observed. A destination outside the tab list matches nothing and keeps
// the current tab.
val matched =
bottomNavScreens.firstOrNull { screen ->
current.hierarchy.any { it.hasRoute(screen.destination::class) }
}
if (matched != null && matched.ordinal != selectedIndex) {
selectedIndex = matched.ordinal
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,21 @@ fun AppBottomNavigationBar(
selectedIndex = BottomNavScreen.Home.ordinal
}
}
// Navigation that does not go through selectTab — above all the system Back button — changes
// the destination without touching selectedIndex, so Back from Library, Mix or Search landed
// on Home with the previous tab still highlighted (#2714). Sync the highlight from the
// destination whenever it changes. A destination outside the tab list matches nothing and
// keeps the current tab.
LaunchedEffect(currentBackStackEntry) {
val current = currentBackStackEntry?.destination ?: return@LaunchedEffect
val matched =
bottomNavScreens.firstOrNull { screen ->
current.hierarchy.any { it.hasRoute(screen.destination::class) }
}
if (matched != null && matched.ordinal != selectedIndex) {
selectedIndex = matched.ordinal
}
}
val selectTab: (BottomNavScreen) -> Unit = { screen ->
if (selectedIndex == screen.ordinal) {
if (currentBackStackEntry?.destination?.hierarchy?.any {
Expand Down
Loading