feedback-assistant / reports

Open collection of Apple Feedback Assistant reports
237 stars 2 forks source link

FB14688465: ScrollView gesture ignored when `DragGesture` used by subview #542

Open Sjmarf opened 3 months ago

Sjmarf commented 3 months ago

Description

I have a view with a horizontal DragGesture. The ScrollView that my view is contained within ignores scroll up/down gestures. This behavior is new in iOS 18 (I have tested dev betas 4 & 5). Example code:

import SwiftUI

struct ContentView: View {
    var body: some View {
        ScrollView {
            ForEach(0..<20) { n in
                TileView(color: n % 2 == 0 ? .red : .blue)
            }
        }
    }
}

struct TileView: View {
    @GestureState var dragState: CGFloat = .zero

    let color: Color

    var body: some View {
        color
            .frame(height: 100)
            .gesture(
                DragGesture(
                    minimumDistance: 10,
                    coordinateSpace: .global
                )
                .updating($dragState) { value, state, _ in
                    state = value.translation.width
                }
            )
            .offset(x: dragState)
    }
}

See attached video of the above script running on iOS 17.5 (left) and iOS 18 dev beta 5 (right).

In the above example, the scroll gesture is always ignored. In my actual app, scroll gestures are only sometimes ignored.

Built using Xcode beta 5, happens on a sim (22A5326g) and on my physical device (22A5326f).

Files

https://github.com/user-attachments/assets/a8923fce-2a92-4276-b351-83c327680a26