Skip to content

Incorrect controller stack in NavigationStackController when using fluid transitions #319

Description

@7hommay

Description

When using fluid transitions it is possible to start presenting a controller while a dismissal of a previous controller is still in progress. Currently the library doesn't handle this correctly. I encountered this issue while working on an app with a similar setup to the StaticNavigationStackController case study.

Checklist

  • I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

Expected behavior

When appending to the path while a dismissal animation is still running, the path should reflect the new target state.

Actual behavior

When appending for example feature2 to the path while a dismissal animation for feature 1 is still running, instead of the path updating to just [feature1] the path updates to [feature1, feature2], thus causing feature1 to be re-presented.

Steps to reproduce

  1. Modify the init method of the StaticNavigationStackController case study:
  convenience init(model: Model) {
    @UIBindable var model = model
    self.init(path: $model.path) {
      RootViewController(model: model)
    }
    self.navigationDestination(for: Model.Path.self) { path in
      let controller = {
        switch path {
        case .feature1:
          FeatureViewController(number: 1)
        case .feature2:
          FeatureViewController(number: 2)
        case .feature3:
          FeatureViewController(number: 3)
        }
      }()
      
      if #available(iOS 18, *) {
        controller.preferredTransition = .zoom(options: nil, sourceViewProvider: { _ in
          nil // Not providing a view here for simplicity, the issue can be triggered without
        })
      }
      
      return controller
    }
    self.model = model
  }
  1. Push any of the first three features and let the animation settle.
  2. Dismiss the opened feature and quickly...
  3. ...open a new feature
Simulator.Screen.Recording.-.iPhone.17.Pro.-.2025-11-04.at.14.25.36.mov

SwiftUI Navigation version information

2.6.0

Destination operating system

iOS 18 +

Xcode version information

Version 26.0.1 (17A400)

Swift Compiler version information

swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
Target: arm64-apple-macosx16.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions