SwiftUI unintentional Root View navigation from sheetView

Viewed 125

I'm having an issue with navigation view and using a popup view to add a core data object. When I dismiss the view instead of going one view back it goes to the root view. This is frustrating especially when you are 5 views in and just want to go back one view.

I've tried many ways to dismiss the view. I have tried different ways of calling and dismissing the popup view including:

Dismissing view:

@Environment(\.presentationMode) var presentationModel

then

self.presentationMode.wrappedValue.dismiss()

Calling and Dismissing view:

@State var showAddObjectView = false

.navigationBarItems(trailing: Button(action: {
            self.showAddObjectView.toggle()
        }) {
            Image(systemName: "plus").imageScale(.large).font(Font.system(.body)).padding(15).accentColor(Color("BlackWhite"))
        }.sheet(isPresented: $showAddObjectView) {
            AddMoodView(showAddMood: $showAddMood, person: person).environment(\.managedObjectContext, self.managedObjectContext)
        })

Then in the sheet view:

@Binding var showAddObjectView: Bool

Then on the save button:

self.showAddMood = false

0 Answers
Related