NavigationSplitView's toolbar item disappears on resize

When a NavigationSplitView's sidebar has a default selected value, the detail's toolbar item disappears when resizing the view from compact to regular size.

@State private var selectedId: String? = "anything"
NavigationSplitView {
    List(selection: $selectedId) {
        Text("Sidebar")
    }
} detail: {
    Text("Detail")
        .toolbar {
            Button("Button") {}
        }
}

There is no way to get the toolbar item back, other than reloading the view. I have no idea why this happens.

In my example I have a dummy Text("Sidebar") without a value, but the problem occurs regardless of its content.

Tested on Simulator iPadOS 18.0, and I've seen this happen in our production app.

Answered by DTS Engineer in 806244022

@vladimirs Please could you open a bug report, include the code snippet and attach the video demonstrating the issue, and post the FB number here once you do. Bug Reporting: How and Why? has tips on creating your bug report.

@vladimirs Please could you open a bug report, include the code snippet and attach the video demonstrating the issue, and post the FB number here once you do. Bug Reporting: How and Why? has tips on creating your bug report.

Filed a bug report: FB15300614

I've noticed that this problem occurs as soon as selectedId gets set a value, then persists even if I remove the selection.

This modified example shows that as long as the selected id does not get set, everything works as expected. When you select tap "Option", the selection is set, and my problem occurs as shown in the video above.

Even if I remove the selection by tapping "Unselect", the problem still persists.

@State var selectedId: String? = nil
NavigationSplitView {
    List(selection: $selectedId) {
        NavigationLink("Sidebar", value: "test")
        Button("Unselect") {
            selectedId = nil
        }
    }
} detail: {
    Text("Detail")
        .toolbar {
            Button("Button") {}
        }
}
NavigationSplitView's toolbar item disappears on resize
 
 
Q