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

Navigation with nested NavGraph produces error #4678

Closed
Goregius opened this issue Apr 22, 2024 · 1 comment
Closed

Navigation with nested NavGraph produces error #4678

Goregius opened this issue Apr 22, 2024 · 1 comment
Assignees
Labels
bug Something isn't working navigation

Comments

@Goregius
Copy link

Goregius commented Apr 22, 2024

Describe the bug
When using Compose multiplatform navigation, it seems that navigation with a nested NavGraph doesn't work and throws an error when trying to navigate to one.

Affected platforms

  • Desktop (Windows)
  • Web (K/Wasm) - Canvas based API

(I only tested these two)

Versions

  • Kotlin version*: 2.0.0-RC1
  • Compose Multiplatform version*: 1.6.10-dev1593
  • Compose Navigation version: 2.8.0-alpha01
  • OS version(s)* (required for Desktop and iOS issues): Windows 11
  • OS architecture (x86 or arm64): x86
  • JDK (for desktop issues): 17

To Reproduce
Steps and/or the code snippet to reproduce the behavior:

  1. Use a navigation function to create a nested NavGraph and include a route which navigates to a sibling route. For example:

    NavHost(navController, startDestination = "subgraph") {
        navigation(startDestination = "a", route = "subgraph") {
            composable("a") {
                Button(onClick = { navController.navigate("b") }) {
                    Text("Navigate to route b")
                }
            }
            composable("b") {
                Text("Route b")
            }
        }
    }
  2. Launch app and try to navigate to the sibling route.

  3. A similar error to the following will occur:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Navigation destination that matches route b cannot be found in the navigation graph ComposeNavGraph startDestination={ComposeNavGraph route=subgraph startDestination={Destination route=a}}

Expected behavior
The navigation should act as it would in Android, no error should occur.

@Goregius Goregius added bug Something isn't working submitted labels Apr 22, 2024
@MatkovIvan MatkovIvan self-assigned this Apr 23, 2024
@MatkovIvan
Copy link
Member

Already fixed in JetBrains/compose-multiplatform-core#1277

Available in the latest dev build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working navigation
Projects
None yet
Development

No branches or pull requests

2 participants