I ran into basically the same problem. Below is the smallest sample app I came up with demonstrating this issue. It does not happen the first time you navigate in the stack, but on all subsequent times. I filed FB10662166 - feel free to reference in you feedbacks ;-)
import SwiftUI
struct SidebarEntry: Identifiable, Hashable {
let id = UUID()
var localizedName: String
}
let sidebarEntries = [
SidebarEntry(localizedName: "Files"),
SidebarEntry(localizedName: "Bookmarks"),
]
// MARK: - main -
@main
struct NewNavigationTestApp: App {
@State private var sidebarSelection: SidebarEntry?
var body: some Scene {
WindowGroup {
NavigationSplitView {
List(sidebarEntries, selection: $sidebarSelection) { entry in
NavigationLink("\(entry.localizedName)", value: entry)
}
} detail: {
ZStack { // workaround
if let sidebarSelection {
if sidebarSelection.localizedName == "Files" {
TestStackView()
} else if sidebarSelection.localizedName == "Bookmarks" {
Text("Bookmarks View")
} else {
Text("Unknown View")
}
} else {
Text("No selection")
}
}
}
}
}
}
// MARK: - FilesView -
struct TestStackView: View {
var body: some View {
NavigationStack {
List(0 ..< 999) { idx in
NavigationLink("\(idx)", value: idx)
}
}
.navigationTitle("Numbers")
.navigationDestination(for: Int.self) { idx in
Text("Hello")
}
}
}