View in a NavigationSplitView detail looses navigation ToolbarItem after rotation

A ToolbarItem with navigationBar* placement disappears when placed in a toolbar on a detail view of NavigationSplitView.

Expectation: The toolbar item doesn't disappear after device rotation.

Reality: The toolbar item disappears after device rotation.

Reproducible on iPhone 15 Pro Max simulator running 17.4

import SwiftUI

@main
struct MyApp: App {
    @State private var selection: Int?
    @State private var visibility: NavigationSplitViewVisibility = .detailOnly
    var body: some Scene {
        WindowGroup {
            NavigationSplitView(columnVisibility: $visibility) {
                List(1..<10, selection: $selection) { number in
                    NavigationLink(value: number) {
                        Button(number.description) {
                            selection = number
                        }
                    }
                }
            } detail: {
                if let selection {
                    LinearGradient(colors: [.blue, .black], startPoint: .top, endPoint: .bottom)
                        .navigationTitle(selection.description)
                        .navigationBarTitleDisplayMode(.inline)
                        .toolbar {
                            ToolbarItem(placement: .navigationBarTrailing) {
                                Text("A button")
                            }
                        }
                } else {
                    Text("Please make a selection")
                }
            }
        }
    }
}

The problem doesn't exhibit itself when using a NavigationStack instead.

import SwiftUI

@main
struct MyApp: App {
    @State private var selection: Int?
    var body: some Scene {
        WindowGroup {
            NavigationStack {
                List(1..<10) { number in
                    NavigationLink(value: number) {
                        Button(number.description) {
                            selection = number
                        }
                    }
                }
                .navigationDestination(for: Int.self) { selection in
                    LinearGradient(colors: [.blue, .black], startPoint: .top, endPoint: .bottom)
                        .navigationTitle(selection.description)
                        .navigationBarTitleDisplayMode(.inline)
                        .toolbar {
                            ToolbarItem(placement: .navigationBarTrailing) {
                                Text("A button")
                            }
                        }
                }
            }
        }
    }
}

Hi @dav_es ,

This is a known bug. Please file a bug report at https://feedbackassistant.apple.com if you'd like to include your sample project in a bug report to keep track of this!

View in a NavigationSplitView detail looses navigation ToolbarItem after rotation
 
 
Q