Set width of sidebar in macOS using SwiftUI

I'm using a NavigationView to display a SidebarView and DetailView in the window of a Mac app:

Code Block swift
import SwiftUI
private let fruits = ["🍎 Apple", "🥥 Coconut", "🥭 Mango", "🥝 Kiwi"]
struct SidebarView: View {
@Binding var selectedFruit: String?
var body: some View {
List(fruits, id: \.self, selection: $selectedFruit) { fruit in
Text("\(fruit)")
}
.listStyle(SidebarListStyle())
.frame(minWidth: 180, idealWidth: 200, maxWidth: 300)
}
}
struct DetailView: View {
@Binding var fruit: String?
var body: some View {
Text("\(fruit ?? "Default Fruit")")
.font(.headline)
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
struct ContentView: View {
@State private var selectedFruit: String?
var body: some View {
NavigationView {
SidebarView(selectedFruit: $selectedFruit)
DetailView(fruit: $selectedFruit)
}
.frame(width: 500, height: 400)
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}

The width of the SidebarView can be adjusted by dragging the center divider left or right in the window. I would like to have an initial width of 200 defined for the sidebar along with a minimum width of 180 and a max width of 300. I attempted this by setting the frame of the List which does indeed set the max width but the sidebar can still be completely collapsed. Also, the initial width of the sidebar seems to be defined by minWidth not idealWidth.

I am getting the same issues. The only thing is to hope that new releases introduced on WWDC 2020 will fix this.
Howdy folks, if you're still running into this issue please file feedback! If the API doesn't meet your expectations or you find it confusing that's a totally reasonable motivator for feedback :D

Ideally a reduced project like your code above would be great to include while filing.

https://feedbackassistant.apple.com
I filed FB7522157 earlier this year and it looks like this is fixed in the first beta of Big Sur!
In what way was it fixed? Are there new methods available for specifying width and heights for sidebars and detail views
How is this fixed @bkelley ? I would like to know how I can set the width of a sidebar.
Set width of sidebar in macOS using SwiftUI
 
 
Q