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      

BUILD THE ULTIMATE PORTFOLIO APP Most Swift tutorials help you solve one specific problem, but in my Ultimate Portfolio App series I show you how to get all the best practices into a single app: architecture, testing, performance, accessibility, localization, project organization, and so much more, all while building a SwiftUI app that works on iOS, macOS and watchOS.

Get it on Hacking with Swift+

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.