I'm having this odd issue with macOS Montery 3 & Xcode 13 Beta 3, where I get this error with List
's and animations:
[General] Row index 0 out of row range (numberOfRows: 0) for <SwiftUIListCoreOutlineView: 0x133885000>
Its kinda hard to explain, but heres a simple reproduction:
Minimal Reproducible Example
- Create a new SwiftUI macOS application
- Paste this code:
struct ContentView: View {
@State var items = ["Item"]
@ViewBuilder var mainView: some View {
if items.isEmpty {
Text("Im empty")
}
else {
List(items, id: \.self) {s in
Text(s)
}
}
}
var body: some View {
NavigationView {
mainView
.toolbar {
Button(action: {
withAnimation {
items.removeAll()
}
}) {
Image(systemName: "minus")
}
}
Text("Second")
}
}
}
- Run the app, and try resizing the sidebar. (You should be able to)
- Then press the minus button on the toolbar. This simply removes all the items.
- Then, the resizing of the sidebar should be broken. You might also get a bunch of errors in the console.
Is anybody able to reproduce this issue, and is it a bug in SwiftUI?