There is an issue with the NavigationStack in WatchOS 10 when used with TabView: the navigation back from a top bar NavigationLink destination can stay two or three times on the destination when trying to come back to the navigation root.
Here are the conditions for the issue to occur:
TabViewinsideNavigationStackToolbarItemassociated with a tab from theTabView--not the wholeTabViewToolbarItemplaced at.topBarLeadingor.topBarTrailing
Notes:
- Wrapping the tab with a
NavigationStackinsideTabViewfails to run - Placing the
ToolbarItemat.bottomBarworks as expected - Second level
NavigationLinkfrom the destination also works as expected
Is there a way to fix? Or is it a WatchOS 10 issue. Thank you!
Code to replicate the issue:
import SwiftUI
struct ContentView: View {
var body: some View {
NavigationStack {
TabView {
Text("Tab 1")
.toolbar {
ToolbarItem(placement: .topBarLeading) {
NavigationLink() {
Text("Destination")
} label: {
Image(systemName: "hand.tap")
}
}
}
Text("Tab 2")
}
.tabViewStyle(.verticalPage)
}
}
}
Run the app, tap the hand icon, and then tap the caret (or swipe right) to come back to the main screen. (It may require a second take to experience the issue.)