NavigationSplitView TabView Toolbar Clash

I would like to create a master-detail view inside the Settings screen for my Mac app. I am trying to use a NavigationSplitView nested inside the top-level Settings TabView. (Reduced code below).

However, the sidebar of the NavigationSplitView interferes with the TabView - the TabView appears to be in the detail of the NavigationSplitView even though it is its parent. I have seen others having the reverse issues with TabViews in NavigationSplitViews. Is this a known bug please?

struct SettingsView: View {
    var body: some View {
        TabView {
            GeneralSettingsView()
                .tabItem {
                    Label("General", systemImage: "gear") }
                .tag(SettingsSection.general)
            
            TypesView()
                .tabItem {
                    Label("Types", systemImage: "star") }
                .tag(SettingsSection.types)
        }
        .frame(width: 375, height: 150)
    }
}

struct TypesView: View {
    
    @Environment(\.modelContext) private var modelContext
    @Query private var types: [ItemType]
    
    @State private var selectedType: ItemType?
    
    var body: some View {
        NavigationSplitView {
            List {
                    ForEach(types) { type in
                        NavigationLink {
                            TypeView(type: type)
                        } label: {
                            Text(type.name)
                        }
                    }
            }
        } detail: {
            Text("Select a Type")
        }
    }
}
Answered by DTS Engineer in 795837022

@Gillies This isn't a bug, in this case the NavigationSplitView is the content of Types Tab. I would suggest you look into the new TabView API, you could specify a sidebarAdaptable tabViewStyle which shows a sidebar on macOS

@Gillies This isn't a bug, in this case the NavigationSplitView is the content of Types Tab. I would suggest you look into the new TabView API, you could specify a sidebarAdaptable tabViewStyle which shows a sidebar on macOS

Thank you for your answer. I was expecting the sidebar to sit below the tab bar, alongside the detail view. Is there a way to do this on Sonoma? The current behaviour is very strange - it takes two button clicks to return to the Types tab, which then shifts the whole layout. When on the General tab the tab bar remains full width.

I haven't come across a way to do that, you could certainly file an enhancement request via Feedback Assistant with information on how this design decision impacts you, and what you’d like to see done differently.

Keep in mind that since both TabView, NavigationSplitView and NavigationStack are all navigation containers you could experience unexpected behaviors when they are nested because they handles states differently.

OK, thank you for your feedback. I will look to manage the state differently and use a standard HSplitView.

NavigationSplitView TabView Toolbar Clash
 
 
Q