UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Presenting sheet causes view to navigate to root

Forums > SwiftUI

Hi,

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 {
            Spacer()
            Button(action: { self.showEditSheet.toggle() }) { Text("Edit") }
        }).sheet(isPresented: self.$showEditSheet, content: {
            ExerciseEditView(exercise: exercise)
                .environment(\.managedObjectContext, moc)
        })

2      

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?

3      

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.

2      

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 ?

2      

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

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

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

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.