button is pressed when starting scrolling in iOS 18

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()
}

We've run into the same, filed a radar: FB16087048

The ScrollView also seems to be important - if you remove the ScrollView then the button doesn't engage as the sheet begins to drag. Also, List doesn't seem to demonstrate this behavior.

Facing the same issue. Sadly going with List is not an option for my project :(

Just add .highPriorityGesture(DragGesture()) to your ScrollView

.highPriorityGesture(DragGesture()) fixes the tapping when scrolling, but breaks the highlighting of the button when long pressing.

Can you provide your code where you solved this issue? I'm seeing this in my app where I have draggable sheet like this

.sheet { ScrollView { Button { dismiss() } } }

And so when I press and hold on that button and start dragging the sheet down but then let go midway, the sheet bounces back up (as it should) but the button somehow gets triggered and the sheet dismisses anyways, which is annoying.

Setting highPriorityGesture does seem to work, however it also disabled button selection animation, which is not ideal either. Any suggestions?

I'm also seeing this exact issue, and haven't yet found an acceptable fix or workaround. Has anyone been able to work around it without breaking anything else?

Adding another DragGesture to a scroll view has fixed it for me.

ScrollView {
  ...
}
.gesture(
   DragGesture(minimumDistance: 0)
)
button is pressed when starting scrolling in iOS 18
 
 
Q