SwiftUI NavigationLink not triggering on iOS 17 under certain conditions
I'm getting frustrated with I'm experimenting with I'm working on a project and hit a roadblock. I'm working with an scenario with `NavigationLink` in my SwiftUI application on iOS 17. The `NavigationLink` does not seem to trigger the destination view when certain conditions are met, specifically when I have a `List` that contains a `ForEach`. Here's a simplified version of my code: ```swift struct ContentView: View { @State private var selectedItem: Item? let items: [Item] = [...] // Assume this is populated with Item objects var body: some View { NavigationView { List(items) { item in NavigationLink(destination: DetailView(item: item), tag: item, selection: $selectedItem) { Text(item.name) } } .onAppear { selectedItem = nil // Reset selection } } } } ``` When I run this code, tapping on a `NavigationLink` often does nothing, and the console shows the following warning message: "NavigationLink is not triggered because the selection is nil". I've ensured that my `items` array is not empty, and the `DetailView` is working properly when accessed directly. I’ve also tried moving the `List` out of the `NavigationView`, but that caused other layout issues. Additionally, I attempted to change the selection to a non-optional type and ensure my `selectedItem` was being updated by adding a debug print statement, but the behavior remains the same. ```swift .onTapGesture { selectedItem = item print("Selected item: \(selectedItem)") // This logs correctly } ``` This gives me the impression that the `NavigationLink` is somehow not recognizing the selection state correctly when it is initially nil. Has anyone else experienced this scenario or have insights on how to resolve it or work around this behavior? Any suggestions or best practices would be greatly appreciated. Any ideas what could be causing this? I'm open to any suggestions. Hoping someone can shed some light on this. Thanks for any help you can provide!