Post

Replies

Boosts

Views

Activity

Reply to SwiftUI Navigation Stack pops back on ObservableObject update
I fixed the issue by using a button with a navigation link instead of just NavigationLink and now it doesn't pop to the root view when the parent's state changes. Here is the code: struct CustomNavigationLink<Content, Destination>: View where Destination: View, Content: View {   let destination: Destination?   let content: () -> Content   @State private var isActive = false   init(destination: Destination, @ViewBuilder content: @escaping () -> Content) {     self.content = content     self.destination = destination   }   var body: some View {     ZStack {       NavigationLink(destination: destination, isActive: $isActive) {}       Button(action: {         self.isActive = true       }) {         content()       }     }   } }
Sep ’21