android / android/nowinandroid
[Bug] Navigation Failure : launchSingleTop and saveState True Conditions Cause No Action
- Dominant language
- Kotlin
- Stars
- 21.8k
- Forks
- 4.6k
- Avg merge
- 19h 20m
- Merged PRs (30d)
- 2
Description
### Is there an existing issue for this?
- [X] I have searched the existing issues
### Is there a StackOverflow question about this issue?
- [X] I have searched StackOverflow
### What happened?
https://github.com/android/nowinandroid/assets/38935359/ec56c4fb-78f9-41a7-9d7d-797ddfc6a8f9
After investigating issue #997 and reviewing the code, I believed the inability to navigate to the 'ForYou' tab, as demonstrated in the video, was due to both `launchSingleTop` and `saveState` being set to `true`.
Due to `saveState` being set to `true`, when the 'NavBackStack' already contains a 'ForYou destination', it attempts to reuse this destination. However, if `launchSingleTop` is also set to `true`, it tries to create a new 'ForYou Destination' even if it already exists unless the Destination being added is not at the top of the 'NavBackStack'. This conflict seems to result in no action being taken.
Given this, I considered that using `popBackStack` to clear the stack in 'NavBackStack' might work, and indeed, it functioned as anticipated.
https://github.com/android/nowinandroid/assets/38935359/c32d7ea3-8856-4008-b6fe-b6171ade50d8
My question is, when attempting to reuse an existing destination in the 'NavBackStack' with both `launchSingleTop` and `saveState` set to `true`, is it accurate that these settings conflict and lead to no action?
@manuelvicnt, @SimonMarquis, @dturner, @tunjid PTAL..
### Relevant logcat output
_No response_
### Code of Conduct
- [X] I agree to follow this project's Code of Conduct
Contributor guide
Research direction
Start by reproducing the ForYou navigation flow shown in the attached videos and review issue #997 alongside the navigation code that sets launchSingleTop and saveState. Confirm whether the existing NavBackStack state causes the reported no-op, and document the verified behavior and required change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100