diff --git a/ui/navigation/src/main/kotlin/com/getcode/navigation/flow/FlowHost.kt b/ui/navigation/src/main/kotlin/com/getcode/navigation/flow/FlowHost.kt index e97c0133d..0345cb15d 100644 --- a/ui/navigation/src/main/kotlin/com/getcode/navigation/flow/FlowHost.kt +++ b/ui/navigation/src/main/kotlin/com/getcode/navigation/flow/FlowHost.kt @@ -384,6 +384,10 @@ private class InnerFlowNavigator( val nextIndex = anchorIndex + 1 if (anchorIndex >= 0 && nextIndex <= currentSteps.lastIndex) { navigateTo(currentSteps[nextIndex]) + } else if (anchorIndex < 0 && currentSteps.isNotEmpty()) { + // Current step was removed from the steps list (e.g. a gate whose condition + // is now met). Navigate to the first remaining step. + navigateTo(currentSteps.first(), popCurrent = true) } else { val result = completedResult() if (result != null) exitWithResult(result)