Thanks for being a part of WWDC25!

How did we do? We’d love to know your thoughts on this year’s conference. Take the survey here

Allow custom tap gesture in List but maintain default selection gesture

I'm trying to create a List that allows multiple selection. Each row can be edited but the issue is that since there's a tap gesture on the Text element, the list is unable to select the item.

Here's some code:

import SwiftUI

struct Person: Identifiable {
    let id: UUID
    let name: String
    
    init(_ name: String) {
        self.id = UUID()
        self.name = name
    }
}

struct ContentView: View {
    @State private var persons = [Person("Peter"), Person("Jack"), Person("Sophia"), Person("Helen")]
    @State private var selectedPersons = Set<Person.ID>()
    
    var body: some View {
        VStack {
            List(selection: $selectedPersons) {
                ForEach(persons) { person in
                    PersonView(person: person, selection: $selectedPersons) { newValue in
                        // ...
                    }
                }
            }
        }
        .padding()
    }
}

struct PersonView: View {
    var person: Person
    
    @Binding var selection: Set<Person.ID>
    
    var onCommit: (String) -> Void = { newValue in }
    
    @State private var isEditing = false
    @State private var newValue = ""
    
    @FocusState private var isInputActive: Bool
    
    var body: some View {
        if isEditing {
            TextField("", text: $newValue, onCommit: {
                onCommit(newValue)
                isEditing = false
            })
            .focused($isInputActive)
            .labelsHidden()
        }
        else {
            Text(person.name)
                .onTapGesture {
                    if selection.contains(person.id), selection.count == 1 {
                        newValue = person.name
                        isEditing = true
                        isInputActive = true
                    }
                }
        }
    }
}

Right now, you need to tap on the row anywhere but on the text to select it. Then, if you tap on the text it'll go in edit mode.

Is there a way to let the list do its selection? I tried wrapping the tap gesture in simultaneousGesture but that didn't work.

Thanks!

This is super frustrating.

Happens in iOS 17 beta as well.

simultaneousGesture is supposed to solve this issue.

Made a radar for it: FB12683243

can confirm this happens on iOS 17.2 as well.

It seems like the issue is the lists built-in selection and swipe gestures interfere with any added custom gestures.

I have tried using high priority gestures, simultaneous gestures and just regular gestures and none of them seem to allow BOTH the list and the custom gestures to work simultaneously.

I have noticed this issue with quite a few of the UIKit backed swiftui features such as context menus, Lists, Forms, etc...

Maybe it's time that SwiftUI started to get native SwiftUI implementations of these features.

I've encountered the same issue and have filed a FB16488816.

Minimal code for this problem is:

import SwiftUI

struct ContentView: View {
    var body: some View {
        NavigationView {
            List {
                Button("Tap Me") {
                    print("Button action fired")
                }
                .simultaneousGesture(
                    TapGesture().onEnded {
                        print("Custom gesture fired")
                    }
                )
            }
            .navigationTitle("Gesture Collision")
        }
    }
}

Expected Behaviour: Both print("Button action fired") and print("Custom gesture fired") should execute.

Actual Behaviour: Only the custom gesture fires. The button action is completely suppressed.

This also affects NavigationLink, breaking navigation when a tap gesture is attached.

If anyone has a workaround beyond using programmatic navigation or restructuring views, I'd love to hear it. Otherwise, I hope Apple acknowledges and addresses this soon.

Allow custom tap gesture in List but maintain default selection gesture
 
 
Q