Status Update
Comments
ra...@gmail.com <ra...@gmail.com> #2
I suspect this change is the culprit.
jb...@google.com <jb...@google.com>
cl...@google.com <cl...@google.com> #3
Bug reproducible in compose NavHost when compose sets same graph consecutively.
Upon setting same graph the second time, the original _graph
nodes were not properly replaced by the new graph
node instances. When navigating to new destination in addEntryToBackstack
:
findDestination(destination.id)
was not able to find destination node (a new instance) amongst the old nodes (old instances). Therefore it proceeds to re-add new node's hierarchy resulting in duplicated root node.
The fix to
ap...@google.com <ap...@google.com> #4
Branch: androidx-main
commit 5499d88b63726e63900b89d3100be1b3a17b84ce
Author: Clara Fok <clarafok@google.com>
Date: Tue Mar 28 17:00:19 2023
Fix set same graph to replace old destinations
When setting the same graph (exact same routes and destinations but different instances), NavController would keep the original graph but replace the existing graph's nodes with the new graph's nodes. Fix the replace logic to ensure this replacement happens. Also replace backqueue's entry destinations with new instances to ensure the graph and backstack is in sync.
Test: ./gradlew navigation:navigation-compose:cC
Bug: 275258161
Bug: 275407804
Relnote: "When NavController sets the same graph with same route and destinations, it now properly replaces its current graph nodes and its bacstack destinations with new instances."
Change-Id: I5bc582e315578ee53383596070ee3ea4a23aed69
M navigation/navigation-compose/build.gradle
M navigation/navigation-compose/src/androidTest/java/androidx/navigation/compose/NavHostTest.kt
M navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt
cl...@google.com <cl...@google.com> #5
Fixed internally and will be available navigation 2.6.0-alpha09
na...@google.com <na...@google.com> #6
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.navigation:navigation-compose:2.6.0-alpha09
androidx.navigation:navigation-runtime:2.6.0-alpha09
ra...@gmail.com <ra...@gmail.com> #7
It looks good to me. At least, this specific behaviour seems to be fixed.
Description
Component used: Navigation
Version used: 2.6.0-alpha05
Devices/Android versions reproduced on:
Not relevant, it will happen on all.
If this is a bug in the library, we would appreciate it if you could attach: Sample project to trigger the issue.
I'll add a couple of simple kotlin files instead, just use them with any version after 2.6.0-alpha05 navigation dependency and you'll be able to reproduce it.
MainActivity_rook.kt File
If we add destinations directly on "root" (route passed to NavHost call), then this will be the log of the back stack as we navigate:
MainActivity_no_root.kt File
If we add a navigation graph ("home_graph") as the only direct child of "root" and add destinations on that instead, it will work as expected, we'll see this:
This was a breaking change that could introduce bugs for anyone relying on that "root" sent on the NavHost and popping up to that, since after updating navigation it would instead just pop their last screen.