With a navigation hierarchy of more than two layers the NavigationLink in a List or Form will stay selected when navigating back.
Minimal example:
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationView {
List {
NavigationLink(destination: Form {
NavigationLink(destination: Text("Destination")) {
Text("Sublink")
}
}) {
Text("Link")
}
}
}
}
}
Go to the lowest level and pop one back → "Sublink" stays highlighted.
It doesn't matter if it's a Form or List, a NavigationLink or Picker, or SwiftUI/UIKit lifecycle. It also doesn't matter if it's split into multiple components or otherwise separated, so to keep the example short everything is inline.
I've found previous questions on this:
None of the solutions worked for me, but I didn't try force reloading the Lists via .id() as that is really a last resort workaround.
I've also submitted FB9077329 in April, which I haven't had a response to, yet. When i wrote that report I thought this was related to UIKit UINavigationController interoperability (having a mixed hierarchy of ViewControllers and SwiftUI views in the navigation stack), but I can reproduce it with a NavigationView too (as you see in the example).
The screenshot is a slightly modified version of the example above, just with navigationTitles set (doesn't affect the problem, so omitted for brevity).
Edit with some more context: I think this has happened for all of iOS 14 / Xcode 12 and it still happens on iOS 15 / Xcode 13 beta.