I have similar issue, illustrated with this cut-down code and an alert in place of a sheet which always shows the first item, irrespective of the user selection. Its the same in iOS14 and 15.
let items = ["One", "Two", "Three"]
@State private var showAlert: Bool = false
var body: some View {
List {
ForEach(items, id: \.self) { item in
Text(item)
.onTapGesture() {
showAlert = true
}
.alert(isPresented: $showAlert, content: {
Alert(title: Text(item), message: Text(item), dismissButton: .default(Text("OK")))
})
}
}
}
Topic:
UI Frameworks
SubTopic:
SwiftUI
Tags: