All my navigation links suddenly stopped working correctly on my app's companion watch app. I first suspected some issue with my model refreshing causing the NavigationLink to be re-created or such. However, it turned out that even the most simple example is broken.
import SwiftUI
@main
struct cls2_navlinkpushbackApp: App {
var body: some Scene {
WindowGroup {
NavigationView {
ContentView()
}
}
}
}
struct ContentView: View {
@State private var view: Int = 2
var body: some View {
Group {
TabView(selection: $view) {
TestView()
}
}
}
}
struct TestView: View {
var body: some View {
VStack {
Text("Click on the navlink below.")
NavigationLink(destination: LinkView()) {
Text("2) Click me!")
}
}
.navigationTitle(Text("TestView"))
}
}
struct LinkView: View {
var body: some View {
Text("I will pop back immediately :(")
.navigationTitle(Text("LinkView"))
}
}
Whenever a NavigationLink is clicked, the destination target is opened and immediately closed. Can anybody confirm this behaviour? I contacted Apple already through a CLS incident but got the advice to create a feedback request instead (which I'm about todo asap, the ID will be placed here then). However, I wonder why nobody else reported the issue so far if this is indeed a bug.