Skip to content

[BUG] Navigation功能相同代码在1.6.0及以下正常,1.6.1开始异常 #375

Description

@xuhuan

Describe the bug
在不变动代码的情况下,版本1.6.0及以下导航都是正常的,初始化后能正常跳转到默认页。将版本升级到1.6.1或者1.6.2,导航初始化后页面空白,不会进行跳转到默认页。代码显示进行跳转也不会进行。

PreComposeApp {
    val navigator = rememberNavigator()
    NavHost(
        // Assign the navigator to the NavHost
        navigator = navigator,
        // Navigation transition for the scenes in this NavHost, this is optional
        navTransition = NavTransition(),
        // The start destination
        initialRoute = "/home",
    ) {

        打印NavHost日志,所有版本都能打印
        // Define a scene to the navigation graph
        scene(
            // Scene's route path
            route = "/home",
            // Navigation transition for this scene, this is optional
            navTransition = NavTransition(),
        ) {
            打印scene日志,升级到1.6.1及以上这里日志打印不出来
            Text(text = "Hello!")
        }
    }
}

通过日志打印发现1.6.0及以下情况scene里的日志能正常打印,能跳转,内容显示正常。
升级到1.6.1及以上scene里的日志不会打印,且页面空白,不会跳转到默认页。

这种有人碰到过么?大概是什么原因导致的?感谢各位的回复🙏
@Tlaster

Activity

  1. Tlaster commented on Sep 14, 2024

    @Tlaster
    Owner

    我没有办法复现这个问题,可以提供完整的复现repo吗?

  2. xuhuan commented on Sep 18, 2024

    @xuhuan
    Author
        PreComposeApp {
                val navigator = rememberNavigator()
                Scaffold(
                    modifier = Modifier.fillMaxSize(),
                ) { contentPadding ->
                    Box(
                        modifier = Modifier
                            .padding(contentPadding)
                            .fillMaxSize()
                    ) {
                        NavHost(
                            // Assign the navigator to the NavHost
                            navigator = navigator,
                            // Navigation transition for the scenes in this NavHost, this is optional
                            navTransition = NavTransition(),
                            // The start destination
                            initialRoute = "/home",
                        ) {
                            scene(
                                route = "/home",
                            ) {
                                Text(text = "home Hello!")
                            }
                        }
                    }
                }
            }
    

    定位出了问题代码所在,NavHost在Scaffold里面的表现在1.6.0及以下和以上版本的表现是不一样的。1.6.1开始NavHost写在Scaffold里面就会出现之前反馈的问题,路由不会进行跳转。切换到1.6.0就没问题。 @Tlaster

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions