On iOS 18, while on a modal screen, if the scrolling starts on a button, that button gets pressed, outside of a modal this doesn't reproduce, also not reproducible on older iOS versions, neither on modals or outside of them.
The code to reproduce the issue:
import SwiftUI
struct ContentView: View {
@State var presentModal = false
var body: some View {
Button(action: {
presentModal = true
}, label: {
Text("open modal")
})
.sheet(isPresented: $presentModal, content: {
ScrollView {
ForEach(0..<100, id: \.self) { index in
Button(action: {
print("Button \(index) tapped!")
}) {
Text("Button \(index)")
.frame(maxWidth: .infinity)
.frame(height: 100)
.background(randomColor(for: index))
.padding(.horizontal)
}
}
}
})
}
func randomColor(for index: Int) -> Color {
let hue = Double(index % 100) / 100.0
return Color(hue: hue, saturation: 0.8, brightness: 0.8)
}
}
#Preview {
ContentView()
}