In a compact environment (iPhone), navigating from content back to sidebar in a SwiftUI NavigationSplitView is causing a pop transition. The dismissed content view navigates out to the right.
If you experience lag during that transition it might be due to the way you select the content.
@State private var appSection: AppSectionEnum?
NavigationSplitView {
SidebarView(selection: $appSection)
} content: {
switch appSection {
case .search:
SearchView()
case .articles:
ArticlesView()
case .images:
ImageView()
default:
// ArticlesView() DON'T DO THIS
EmptyView() // THIS IS BETTER
}
}
Be sure to not create an expensive view for the content part, if nothing is selected (for example by creating a default article list view in a switch default-case like shown here).
On navigating back, the content view gets rebuilt because the appSection change invalidates the NavigationSplitView. So use something lightweight or even the SwiftUI standard EmptyView().