The same code runs perfectly on iOS, and the behaviour is as expected where whenever the tabview selection is changed, the toolbar items are updated accordingly. On macOS, the toolbar items do not disappear.
import SwiftUI
struct ContentView: View {
var body: some View {
TabView {
Text("Screen 1")
.toolbar {
ToolbarItem {
Text("Item 1")
}
}
.tabItem {
Label("Home", systemImage: "house")
}
Text("Screen 2")
.toolbar {
ToolbarItem {
Text("Item 2")
}
}
.tabItem {
Label("Explore", systemImage: "network")
}
}
}
}
I tried going through all the docs, and I couldn't understand how to figure out this issue. My actual app actually has two different SplitNavigationViews as different items for TabViews, and this is the simplest view where this issue is reproducible.