https://kotlinlang.org logo
Title
b

Bruno Hensel

04/24/2023, 6:35 PM
I found cyclic navigation when the user tries to navigate back off of the stack. I assume this is not the intended behavior.
Screen_recording_20230424_203317.mp4
m

mbonnin

04/24/2023, 6:59 PM
Going from
SessionDetails -> Speaker -> SessionDetails -> Speaker
right?
b

Bruno Hensel

04/24/2023, 7:00 PM
Yeah, then pressing back button.
m

mbonnin

04/24/2023, 7:01 PM
What would be the intended behaviour? It's a bit weird here because it loops on Chet's talk but you can theorically do something else: •
Some UI Talk
Chet Haase
Some Other Comedy Talk
Romain Guy
Some Romain Guy Talk
• etc...
Looking in the backstack for similar ids maybe?
But then it becomes really hard to predict the logic
b

Bruno Hensel

04/24/2023, 7:03 PM
Yeah, it’s a bit tricky. Maybe check the back stack, if the destination composable is the last added to back stack, we just navigate back instead of creating a new composable. Wdyt?
But then we would need to know the ids used in the route so we can compare them to know that the exact same composable is the previous one.
m

mbonnin

04/24/2023, 7:04 PM
Works for me. I'm not sure there's a generally "good" answer to that probelm
m

Marcello Galhardo

04/24/2023, 7:05 PM
There is an option on navigation that navigates to the route back in the back stack if it already exists.
m

mbonnin

04/24/2023, 7:06 PM
But then it's potentially an issue if you have a permutation with more than 2 destinations
m

Marcello Galhardo

04/24/2023, 7:07 PM
I'm out of my computer now, can look for it later. But should be in the options lambda.
m

mbonnin

04/24/2023, 7:07 PM
A -> B -> C. Navigating to A pops B forever
At least this is how I would imagine things to work?
m

Marcello Galhardo

04/24/2023, 7:07 PM
@mbonnin I think it "brings" the navigation entry to the top, actually. Not super sure.
m

mbonnin

04/24/2023, 7:08 PM
Mmm I see
b

Bruno Hensel

04/24/2023, 7:08 PM
do you mean the
launchSingleTop = true
?
m

Marcello Galhardo

04/24/2023, 7:08 PM
Anyway, we may be overthinking a little. The current behaviour (or skip a few) won't cause much issues IMO.
What I would personally do is to not navigate the whole screen.
m

mbonnin

04/24/2023, 7:08 PM
Agree, at the end of the day, it's "okay"
b

Bruno Hensel

04/24/2023, 7:09 PM
I’ve tried a couple of approaches but didn’t get it right so far. =(
m

Marcello Galhardo

04/24/2023, 7:09 PM
But only the content of the tab, so if the user presses the tab it cuts the back stack.
That is the main advantage of having multi back stack support, which Navigastion has.
m

mbonnin

04/24/2023, 7:10 PM
Ah yea, allowing to go back to top level without having to press back 50 times sounds interesting 🙂
I've seen apps where clicking to the currently focused tab would also reset it to the top level
m

Marcello Galhardo

04/24/2023, 7:12 PM
Yes, exactly.