TEAM LICENSES: Save money and learn new skills through a Hacking with Swift+ team license >>

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      

Hacking with Swift is sponsored by RevenueCat.

SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.

Learn more here

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.