Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Darkrai9x opened this issue Apr 23, 2024 · 0 comments · Fixed by JetBrains/compose-multiplatform-core#1311
Closed
Assignees
Labels
bug Something isn't working crash navigation

Comments

@Darkrai9x
Copy link

Darkrai9x commented Apr 23, 2024

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

  • Desktop (Windows, Linux, macOS)
  • iOS

Versions

  • Kotlin version*: 1.9.23
  • Compose Multiplatform version*: 1.6.10-dev1596
  • Navigation version*: 2.8.0-dev1596
  • OS version(s)* (required for Desktop and iOS issues):
  • OS architecture (x86 or arm64): x86
  • Device (model or simulator for iOS issues): simulator iPhone 15 17.4
  • JDK (for desktop issues): 17

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

@Darkrai9x Darkrai9x added bug Something isn't working submitted labels Apr 23, 2024
@MatkovIvan MatkovIvan self-assigned this Apr 23, 2024
MatkovIvan added a commit to JetBrains/compose-multiplatform-core that referenced this issue Apr 23, 2024
Getting parent `BackStackEntry` by `destination` reference - no need to
use string/links matching logic here.

## Testing

Test: manually for now, unit tests are in progress.

## Issues Fixed

Fixes JetBrains/compose-multiplatform#4684
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working crash navigation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants