NEW: Start my new Ultimate Portfolio App course with a free Hacking with Swift+ trial! >>

Presenting sheet causes view to navigate to root

Forums > SwiftUI


I have a weird problem with nav. In my root (home) view I use a tabbar. I'm picking tabItem 1 (a listview), from there, I click a row to see the details. From within the detail view, I have an edit button on the navbar.

When I hit edit, I have a sheet being presented to make changes. That works fine -- but the second the sheet opens, I can see in the background that I'm navigated all the way back to the root (home) view, with tabItem 0 selected (all the while, the sheet remains open).

Is there something I'm missing here? Or is this a bug? I don't want it to do this :( I want the user to stay where they pressed the 'Edit' button.

        .navigationBarItems(trailing: HStack {
            Button(action: { self.showEditSheet.toggle() }) { Text("Edit") }
        }).sheet(isPresented: self.$showEditSheet, content: {
            ExerciseEditView(exercise: exercise)
                .environment(\.managedObjectContext, moc)


I have a similar problem.

I have a "Feed View" (or home/root) where I have a tab bar, and one of tab bar menu points is a NavgationView with three sub views. I am asking the user to create a post across three views (see screenshots). In these sub views I'm using a sheet to get info like dates and such. But every time I present a sheet, the user is sent back to the root/home view.

Anyone else with that issue?


Oddly; this problem is no longer presenting itself for me though I can't for the life of me see what I might have done to fix it.


Hi, I have the exact same problem ! Do you have any explanation on how to make the tabs don't go to the root when we call a sheet ?


Hacking with Swift is sponsored by Instabug

SPONSORED Catch bugs as soon as they happen and know exactly why a crash occurred. Instabug's SDK grabs all the logs they need to fix bugs, crashes and performance issues in minutes instead of days. Get screenshots, device details, network logs, repro steps, and tons of other critical insights needed to resolve issues and prioritize product backlogs straight from your dashboard. It only takes a minute to integrate!

Get started now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Reply to this topic…

You need to create an account or log in to reply.

All interactions here are governed by our code of conduct.

Unknown user

You are not logged in

Log in or create account

Link copied to your pasteboard.