From 0e4379c5bf70e5fe3c952011aa503dce90d6d57a Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 27 Apr 2026 18:39:23 +0000 Subject: [PATCH] fix(nav): clear back stack on bottom-nav taps so no back arrow shows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit popUpTo(route) { inclusive = true } only pops if `route` is already in the stack. From Home, tapping any other bottom-nav tab left Home in the back stack, so canPop() returned true and the back arrow appeared on a root tab. Pop up to the graph's start destination instead (also inclusive). This clears Home — and any drawer/deep-push entries above it — before navigating to the new bottom-nav root, so each bottom-nav tap leaves exactly one entry in the stack. https://claude.ai/code/session_01PrirRcL7g8iX7vTqqLTkBS --- .../com/vitorpamplona/amethyst/ui/navigation/navs/Nav.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/navs/Nav.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/navs/Nav.kt index f95068d8a..89f05c7ab 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/navs/Nav.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/navigation/navs/Nav.kt @@ -24,6 +24,7 @@ import android.annotation.SuppressLint import androidx.compose.material3.DrawerState import androidx.compose.material3.DrawerValue import androidx.compose.runtime.Stable +import androidx.navigation.NavGraph.Companion.findStartDestination import androidx.navigation.NavHostController import com.vitorpamplona.amethyst.ui.navigation.SKIP_SLIDE_ANIMATION_KEY import com.vitorpamplona.amethyst.ui.navigation.routes.Route @@ -78,7 +79,11 @@ class Nav( override fun navBottomBar(route: Route) { navigationScope.launch { controller.navigate(route) { - popUpTo(route) { + // Clear the back stack down to and including the graph's start + // destination so a bottom-nav tap leaves only the new route in + // the stack. Without inclusive=true, Home would remain below + // the new tab and canPop() would wrongly show a back arrow. + popUpTo(controller.graph.findStartDestination().id) { inclusive = true } launchSingleTop = true