-
Notifications
You must be signed in to change notification settings - Fork 70
Fix Back Navigation for Same Fragment Launches #3755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3755 +/- ##
=========================================
- Coverage 25.0% 25.0% -0.1%
Complexity 844 844
=========================================
Files 297 297
Lines 16102 16107 +5
Branches 2689 2690 +1
=========================================
Hits 4038 4038
- Misses 11580 11585 +5
Partials 484 484
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes an issue with back navigation when launching the same fragment by adjusting the navigation options configuration.
- Removed the unnecessary else clause and replaced it with a clear early return for same register navigation.
- Introduced a NavOptions.Builder() with setLaunchSingleTop(true) and conditional pop-up behavior based on the current back stack state.
val navOptionsBuilder = NavOptions.Builder().setLaunchSingleTop(true) | ||
|
||
if ( | ||
actionConfig.popNavigationBackStack == true && | ||
navController.currentBackStackEntry?.destination?.id != MainNavigationScreen.Home.route | ||
) { | ||
navController.currentBackStackEntry?.destination?.id?.let { | ||
navOptionsBuilder.setPopUpTo(it, inclusive = true) | ||
} | ||
} | ||
|
||
navController.navigate( | ||
resId = MainNavigationScreen.Home.route, | ||
args = args, | ||
navOptions = navOptionsBuilder.build(), |
Copilot
AI
Jun 20, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider extracting the navigation options configuration into a helper method to improve readability and ease future modifications.
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This nitpick is a valid review. Refactor this by extracting the functionality into its own method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FikriMilano Did you get a chance to test this functionality?
@qiarie could you fix the CI failures. |
- Bump up versionName to 2.1.4
IMPORTANT: Where possible all PRs must be linked to a Github issue
Fixes [link to issue]
Engineer Checklist
strings.xml
file./gradlew spotlessApply
and./gradlew spotlessCheck
to check my code follows the project's style guideCode Reviewer Checklist
strings.xml
file