I can’t figure out how to get the Bottom Nav to re...
# compose
t
I can’t figure out how to get the Bottom Nav to remain selected for nested destinations. I’m using this:
Copy code
BottomNavigationItem(
          ...,
          selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true,
My nav hierarchy looks like so:
Copy code
NavHost {
    navGraphA()
    navGraphB()
    navGraphC()
}
Where A, B and C represent top-level bottom navigation graphs.
Copy code
fun NavGraphBuilder.screenAGraph(navController: NavController) {
    navigation(
        startDestination = "screen_a",
        route = "screen_a_graph"
    ) {
        composable("screen_a_graph") {
            ScreenA(onClick = { navController.navigate("screen_b") })
        }
        
        screenBGraph()
    }
}

fun NavGraphBuilder.screenBGraph() {
    composable(
        route = "screen_b"
    ) {
        ScreenB()
    }
}
When I navigate to Screen B, it seems that neither
screen_a
nor
screen_a_graph
are present in the
currentDestination.hierarchy
I’ve searched this chat and Googled around but I just can’t seem to find an answer. Am I approaching this the wrong way?