I ran into the same problem and was able to resolve it by replacing the "NavigationLink(value:" with a button instead:
// Used for programmatic navigation
@EnvironmentObject var router: Router
Button {
router.path.append(SettingsView())
} label: {
Label("Settings", systemImage: "gearshape")
}
class Router: ObservableObject {
@Published var path = [Destination]()
func goBack() {
// Navigate back to the previous view
path.removeLast()
}
func goToRoot() {
// Navigate back all the way to the root view
path = []
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: