First, I'd like to emphasize that with a ScrollView instead of List, this issue doesn't happen.
I have created this test code:
import SwiftUI
struct ContentView: View {
var body: some View {
List {
VStack { //this VStack messes up the context menu
Button("1", action: {})
.contextMenu {
Button {
print("hi")
} label: {
Text("test")
}
}
Button("2", action: {})
.contextMenu {
Button {
print("hi")
} label: {
Text("test")
}
}
Image(systemName: "globe")
.imageScale(.large)
.foregroundColor(.accentColor)
Text("Hello, world!")
}
}
.padding()
}
}
The result when long pressing to show the context menu is that the whole VStack is the context menu (instead of just the button)
Also attaching what is looks like when I comment out the VStack:
Is this an Apple bug? is there a way to get this to work with the VStack? In my real app, I have many sections with horizontal stacks and obviously a real app cannot be built without VStack or HStack (lazy or not)
