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

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

Open
xuhuan opened this issue Sep 14, 2024 · 2 comments

Comments

@xuhuan
Copy link

xuhuan commented Sep 14, 2024

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

@Tlaster
Copy link
Owner

Tlaster commented Sep 14, 2024

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

@xuhuan
Copy link
Author

xuhuan commented Sep 18, 2024

    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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants