[NAVIGATION} Are we aware of a behaviour change th...
# compose
r
[NAVIGATION} Are we aware of a behaviour change that makes all navigation actions re-add routes already present? For example, I have root nav graph (passed to NavHost) and A, B destinations. If A is start destination, then back stack looks like
[root, A]
. When I navigate from A to B, then I would expect to have
[root, A, B]
(like it was before) but now in latest navigation versions (I still haven't figured out what version exactly changed this) I'm getting
[root, A, root, B]
. This can have impact if the user is calling
popUpTo(root)
. Is this known and intended or a regression?
@Ian Lake again I hope you don't mind my audacity of tagging you, but I feel like you are interested in the topic and can probably give me an answer in 1min within reading the question 😄
i
Unless you specifically navigate to
root
(which will create a new copy of
root
on the back stack), navigating to
B
should reuse the existing copy. File a bug if you are seeing something different
r
Perfect, this is all I needed to know, thanks Ian. I will just make sure it's nothing on my side before I submit something. But it does look like if nothing changes and I just change navigation dependency version, it starts working as expected, so even if I'm doing something weird, it would still be some kind of breaking change. But I want to confirm all this first, now that I know this is not the intended behaviour 🙂
Just in case you're curious, I found this change in NavController class that seems suspicious (method
addEntryToBackStack
). Still gonna do more tests though:
So yes, I was able to confirm that this change which was introduced in
2.6.0-alpha05
is the cause of the behaviour I'm seeing. Only by changing from
2.6.0-alpha04
to
2.6.0-alpha05
I start seeing this behaviour, and it matches the left and right side of the diff image shown above.
I'll report it as soon as I can.
I learnt while preparing this issue that the same doesn't happen for nav graphs other than the "root" one that we pass to NavHost call. If we add a nav graph as the only direct child of this "root", we won't see this issue. Still, it feels like quite problematic and can introduce bugs for anyone relying on this "root" and popping to it (since now it would only pop their top most destination).
Issue fixed on 2.6.0-alpha09! 🙌
i
Thank you for filing the issue, it was very helpful