JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
16.27k stars 1.18k forks source link

[iOS][Desktop] BottomNavigation crash when switch tab #4684

Closed Darkrai9x closed 6 months ago

Darkrai9x commented 6 months ago

Describe the bug When I implement BottomNavigation following the guidelines on Google, it crashes when switching between tabs on iOS and desktop, while it works fine on Android.

Affected platforms

Versions

To Reproduce

val rootRoutes = remember {
    listOf(
        CupcakeScreen.Start.name,
        CupcakeScreen.Flavor.name,
        CupcakeScreen.Pickup.name,
        CupcakeScreen.Summary.name,
    )
}

Row(modifier = Modifier.fillMaxWidth()) {
    rootRoutes.forEachIndexed { i, route ->
        Button(
            onClick = {
                navController.navigate(
                    route,
                    navOptions {
                        navController.graph.findStartDestination().route?.let {
                            popUpTo(it) { saveState = true }
                        }
                        launchSingleTop = true
                        restoreState = true
                    }
                )
            }
        ) {
            Text("Tab $i")
        }
    }
}

When switching between tabs 1, 2, 3, 4, it crashes when switching from tabs 2, 3, 4 back to tab 1. Expected behavior It works like on Android.

Screenshots image

okushnikov commented 4 months ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.