List items do not appear to be moveable when they are contained within a popover
on Mac Catalyst running on macOS Sonoma. Dragging and dropping a list item simply returns it to its original location, and onMove(preform:)
is not called. The same happens using the drag handles with an EditButton()
or .environment(\.editMode, .constant(.active))
.
Below is a reproducible sample which, to my knowledge, worked as expected on Ventura. It also currently works as expected on iPad. Changing the popover
to a sheet
makes it work on Mac Catalyst, but then, the view takes up a lot of unnecessary space.
Does anyone have any good workarounds for this issue?
struct ContentView: View {
@State private var isShowingPopover = false
@State private var items = ["one", "two", "three"]
var body: some View {
Button("Show Popover") {
isShowingPopover = true
}
.popover(isPresented: $isShowingPopover) {
List {
ForEach(items, id: \.self) { item in
Text(item)
}
.onMove { fromOffsets, toOffset in
items.move(fromOffsets: fromOffsets, toOffset: toOffset)
}
}
.frame(minWidth: 300, minHeight: 270)
}
}
}