Skip to content

Commit

Permalink
CMP-7240: Update non-android navigateUp to handle single-entry back s…
Browse files Browse the repository at this point in the history
…tack correctly (#1736)

Previously, we cleared the backstack completely on navigation up on a
root screen.

Describe proposed changes and the issue being fixed

Fixes https://youtrack.jetbrains.com/issue/CMP-7240

## Release Notes
### Fixes - Navigation
- Fix incorrect navigation up on the root screen for non-android targets
  • Loading branch information
terrakok authored Dec 16, 2024
1 parent 11a8a8e commit 11a1ac8
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -672,8 +672,13 @@ public actual open class NavController {

@MainThread
public actual open fun navigateUp(): Boolean {
// TODO If there's only one entry, then we may have deep linked into a specific destination
return popBackStack()
if (destinationCountOnBackStack == 1) {
// opposite to the android implementation, we don't start a new window for deep links,
// so we mustn't reopen an initial screen here
return false
} else {
return popBackStack()
}
}

/** Gets the number of non-NavGraph destinations on the back stack */
Expand Down

0 comments on commit 11a1ac8

Please sign in to comment.