Skip to content

Presenting to parent Navigator doesn't work properly #92

@MatuskaDev

Description

@MatuskaDev

Hello 👋,

I found a really strange navigation issue when I have a root ManagedNavigationStack which has TabBar inside and each tab has its own ManagedNavigationStack.

The issue happens when I try to push new view from the inner ManagedNavigationStack to the root one (I want the new view to be above the TabBar), then when I dismiss the pushed view using system back button and repeat this several times I see that multiple views were pushed to the stack (note: if you use navigator.pop() this issue doesn't happen, it's only happening with the system back button and back gesture)

Here is a code example which produces the above described issue (tested on the newest Navigator 1.4.6):

struct ContentView: View {
    var body: some View {
        ManagedNavigationStack { rootNavigator in
            ZStack {
                TabView {
                    ManagedNavigationStack { tabNavigator in
                        VStack {
                            // Tap this button, then tap the system back button - repeat several times to see the issue
                            Button("Present above TabBar") {
                                rootNavigator.navigate(to: TestNavigationDestination.test)
                            }
                            
                            Button("Present below TabBar") {
                                tabNavigator.navigate(to: TestNavigationDestination.test)
                            }
                        }
                    }
                }
            }
        }
    }
}

enum TestNavigationDestination: NavigationDestination {
    case test
    
    var body: some View {
        ProgressView()
    }
}

Expected behavior

  • After tapping Present above TabBar the view should sit above the TabBar
  • After tapping Present below TabBar the view should sit below the TabBar

How can I achieve this behavior without the multiplying stack issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions