fix: prevent popping the last item from backStack if it's the only item

This commit is contained in:
2026-02-18 12:07:30 +01:00
parent f215c93608
commit a4b28b1dc7

View File

@@ -155,7 +155,7 @@ class PurefinActivity : ComponentActivity() {
LaunchedEffect(navigationManager, backStack) {
navigationManager.commands.collect { command ->
when (command) {
NavigationCommand.Pop -> backStack.removeLastOrNull()
NavigationCommand.Pop -> if (backStack.size > 1) backStack.removeLastOrNull()
is NavigationCommand.Navigate -> backStack.add(command.route)
is NavigationCommand.ReplaceAll -> {
backStack.clear()
@@ -168,6 +168,7 @@ class PurefinActivity : ComponentActivity() {
CompositionLocalProvider(LocalNavigationManager provides navigationManager) {
NavDisplay(
backStack = backStack,
onBack = { navigationManager.pop() },
modifier = Modifier.fillMaxSize(),
entryDecorators =
listOf(