Post

Replies

Boosts

Views

Activity

Reply to `NavigationSplitView` with `ZStack` in detail view causes `.sheet(item` to hang
Thank you @DTS Engineer . Here is an example from the WWDC session "What's new with SwiftUI". It isn't a great experience, because when the user switches between menu items state of the detail view is recreated. Scroll position, textfield values, and @State in FoodOverview() or MusicOverview() are lost. This challenge is in all SwiftUI versions, not just MacOS 13.6. The workaround I use is to wrap the detail view in a ZStack. The problem on MacOS 13.6 is using ZStack makes .sheet buggy. I haven't tried the beta - I need to solve on 13.6. @State var selectedTask: PartyTask? var body: some View { NavigationSplitView { List(PartyTask.allCases, selection: $selectedTask) { NavigationLink(value: $0) { TaskLabel(task: $0) } } } detail: { switch selectedTask { case .food: FoodOverview() case .music: MusicOverview() } } } }
Aug ’24