For some reason, clearing a navigation stack gives an unintended animation when compared to dismissing regularly. It clears the screen before it actually animates away. How can you pop back to root normally without the clearing of the screen?
struct ContentView: View {
@State var navigationPath: NavigationPath = NavigationPath()
var body: some View {
NavigationStack(path: $navigationPath) {
ZStack {
Color.red
NavigationLink(value: 0) {
Text("test")
}
}
.navigationDestination(for: Int.self) { _ in
SubView(navigationPath: $navigationPath)
}
}
}
}
struct SubView: View {
@Binding var navigationPath: NavigationPath
var body: some View {
ZStack {
Color.green
Button {
navigationPath = NavigationPath()
} label: {
Text("back")
}
}
}
}
Button
on the green page. What environment are you using?