Skip to content

Commit 50c4526

Browse files
committed
fix(navigation): handle removed step in FlowHost proceed()
When the current step is removed from the steps list (e.g. a gate whose condition is now met), proceed() now navigates to the first remaining step instead of doing nothing. Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent af85eb0 commit 50c4526

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • ui/navigation/src/main/kotlin/com/getcode/navigation/flow

ui/navigation/src/main/kotlin/com/getcode/navigation/flow/FlowHost.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,10 @@ private class InnerFlowNavigator<S : FlowStep, R : Parcelable>(
384384
val nextIndex = anchorIndex + 1
385385
if (anchorIndex >= 0 && nextIndex <= currentSteps.lastIndex) {
386386
navigateTo(currentSteps[nextIndex])
387+
} else if (anchorIndex < 0 && currentSteps.isNotEmpty()) {
388+
// Current step was removed from the steps list (e.g. a gate whose condition
389+
// is now met). Navigate to the first remaining step.
390+
navigateTo(currentSteps.first(), popCurrent = true)
387391
} else {
388392
val result = completedResult()
389393
if (result != null) exitWithResult(result)

0 commit comments

Comments
 (0)