Status Update
Comments
jb...@google.com <jb...@google.com>
ap...@google.com <ap...@google.com> #2
Is this specific to navigation? Or can this be reproduced with another other Composable component?
jb...@google.com <jb...@google.com> #3
It only happens inside of a NavHost. So, yes, it seems to be specific to navigation.
wb...@gmail.com <wb...@gmail.com> #4
This was caused by the fix to BackHandler
lifecycle aware. The problem here is that the NavController
registers its lifecycle and added an observer to the Activity
Lifecycle
in composition while the BackHandler
registers its observer on the Activity
Lifecycle
in a DisposbleEffect
. This means that the NavController
will always get Lifecycle callbacks before the BackHandler
, so the components listening the the NavController
's lifecycle (like the NavBackStackEntry) will always get their Lifecycle callbacks before the BackHandler
as well.
This should be addressed by work coming in 2.7 to integrate the BackHandler
into the NavHost
.
jb...@google.com <jb...@google.com> #5
Branch: androidx-main
commit d2c5efe67531a30fb9f1a129d52beb1e9ece0b29
Author: Jeremy Woods <jbwoods@google.com>
Date: Wed May 31 23:09:54 2023
Integrate BackHandler into NavHost
Instead of NavHost taking over the onBackPressedDispatcher from the
Activity, we should just make it use a BackHandler. This will ensure
that it interacters with the other BackHandlers in Compose correctly.
RelNote: "`NavHost` now correctly intercepts system back calls even
after the Activity has been `STOPPED` and `RESUMED`."
Test: modified tests
Bug: 279118447
Change-Id: Icb6deab996d122487243f0d3d775af8c15fc7c25
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostTest.kt
M navigation/navigation-compose/src/main/java/androidx/navigation/compose/NavHost.kt
wb...@gmail.com <wb...@gmail.com> #6
This has been fixed internally and will be available in Navigation 2.7.0-beta01.
Description
Version used: 2.4.0-rc01
Devices/Android versions reproduced on:
Pixel 6 / Android 12
In the example project I have the following nested nav graph structure:
nav_graph{ startDestination=home
home {...}
list { startDestination=leaderboard
leaderboard
exampleNestedGraph { startDestination=exampleFragment
exampleFragment - deepLink="
userProfile - deepLink="
}
}
form {...}
}
Following the deep link:
Then clicking back pops to the exampleFragment
Expected: Clicking back again takes the user to the leaderboard fragment, then clicking back a final time takes the user back to the home fragment.
Actual: Clicking back takes the user to the home fragment, skipping the leaderboard fragment.
I've also updated the bottomNavView_DeepLink_HandlesIntent_BackGoesToList test to test this case
It looks like this was introduced with