'SwiftUI Context Menu Has Extra Scrollable Space For No Reason
I have a list of items, each with a .contextMenu. The menu works, but for some reason it is scrollable and has extra empty space above all buttons.


My simplified code. This view is a list item in a scrollable list:
GeometryReader { geometry in
ZStack(alignment: .leading) {
//custom view here
}
}
.contextMenu {
Button(action: {
//action here
}, label: {
Label("Edit", systemImage: "square.and.pencil")
})
Button(role: .destructive, action: {
//action here
}, label: {
Label("Delete", systemImage: "trash")
})
}
What am I doing wrong?
Solution 1:[1]
I have UIScrollView.appearance().contentInset = UIEdgeInsets(top: 200, left: 0, bottom: 0, right: 0) for an unrelated ScrollView, but turns out that this affects the contextMenu as well. I assuming context menu is a scrollview under the hood.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Grant Oganyan |
