Perhaps I'm particularly dense this morning but I'm trying to delete a row from a List in SwiftUI on macOS.
The issue is that there is no UI exposed to perform the delete. By that I mean that the List does not respond to delete key presses, has no right click menu nor supports any other gestures like swipe to delete (which would be odd on macOS anyway).
Here's the example I'm using:
import SwiftUI
struct ContentView: View {
@State var items = ["foo", "bar", "baz"]
@State var selection: String? = nil
var body: some View {
List(selection: $selection) {
ForEach(items, id: \.self) { Text($0) }
.onDelete { self.items.remove(atOffsets: $0)}
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
}
The exact same code on iOS gives me a table view with the standard "swipe left to delete" UI. On macOS there is just nothing.
I tried adding
.onDeleteCommand(perform: {
if let sel = self.selection, let idx = self.items.firstIndex(of: sel) {
self.items.remove(at: idx)
}
})
to the List but still no response to delete key presses.
How does one enable List row deletion on macOS?

.environment(\.editMode, .constant(.active))gives me'editMode' is unavailable in macOS