Sidebar inset spacing changes on rotation and reload - SwiftUI

I have a SwiftUI app that uses a sidebar on iPad. I can not figure out why the edge spacing does not apply, however when I force close the app and reopen it appears normal.

Problem:

  • When user first signs in
  • rotates device
  • collapses sidebar and reopens)

The problem goes away when force quitting the app and reloading when user is signed in.

ContentView

struct ContentView: View {

    var body: some View {
        #if os(iOS)
        if horizontalSizeClass == .compact {
            AppTabView()
                .environmentObject(store)
                .environmentObject(quickActionSettings)
        } else {
            AppSideNavView()
                .environmentObject(store)
        }
        #else
        AppSideNavView()
            .environmentObject(store)

        #endif
    }
}

AppSideNavView (For iPad)

struct AppSideNavView: View {
    
    @EnvironmentObject var store: Store

    var body: some View {
        if store.userAuthState == .signedOut {
            LoginView()
        } else if store.userAuthState == .signedIn {
            AppSidebarNavigation()
                .environmentObject(store)
        } else {
             LoginView()
        }
    }
}

Sidebar

struct AppSidebarNavigation: View {
    
    enum NavigationItem {
        case home
        case expenses
    }
    
    @EnvironmentObject var store: Store
    @State private var selection: NavigationItem? = .home

    var body: some View {
        NavigationView {
            sidebar
                .navigationTitle("")
                .navigationBarTitleDisplayMode(.inline)
                .navigationBarHidden(true)
            
            HomesView()
                .environmentObject(store)
        }
        .navigationViewStyle(DoubleColumnNavigationViewStyle())

    }
}

extension AppSidebarNavigation {
    
    var sidebar: some View {
            List(selection: $selection) {
                Group {
                    NavigationLink(destination: HomesView()
                        .environmentObject(store), tag: NavigationItem.home, selection: $selection) {
                            Label("Homes", systemImage: "house")
                                .modifier(navText())
                            
                        }
                        .tag(NavigationItem.home)
                    
                    NavigationLink(destination: ExpensesView()
                        .environmentObject(store)
                        .navigationBarTitleDisplayMode(.large),
                        tag: NavigationItem.expenses, selection: $selection) {
                            Label("Expenses", systemImage: "arrow.right.arrow.left")
                                .modifier(navText())
                            
                        }
                        .tag(NavigationItem.expenses)
                }

            }
            .listRowBackground(Color("White"))
            .background(Color("White"))
            .listStyle(.sidebar)
    }
}

Maybe give the ContentView your root view, some padding.

Sidebar inset spacing changes on rotation and reload - SwiftUI
 
 
Q