Simultaneous TapGesture on Button in List Prevents Button Action from Firing
Originator: | ncreated | ||
Number: | rdar://FB16488816 | Date Originated: | 12 Feb 2025 |
Status: | Open | Resolved: | |
Product: | SwiftUI | Product Version: | |
Classification: | Reproducible: |
## Summary When I attach a custom TapGesture to a Button or NavigationLink inside a SwiftUI List, the system’s built-in gesture for the control no longer fires. Taps trigger only my custom gesture, while the standard button action (or navigation) is ignored. This happens even when using `.simultaneousGesture(..., including: .all)`, which the documentation suggests should allow both gestures to succeed. ## Steps to Reproduce 1. Create a new SwiftUI project with Xcode. 2. In ContentView, add a List containing a Button. 3. Attach a simultaneous tap gesture (e.g., via `.simultaneousGesture()`) to that Button. Here’s minimal sample code: ``` import SwiftUI struct ContentView: View { var body: some View { NavigationView { List { Button("Tap Me") { print("Button action fired – expected!") } .simultaneousGesture( TapGesture().onEnded { print("Custom gesture fired") } ) } .navigationTitle("Gesture Collision") } } } ``` ## Expected Results When the user taps on the button, both the button’s standard action (`print("Button action fired”)`) and the custom gesture (`print("Custom gesture fired”)`) should execute, since `.simultaneousGesture(..., including: .all)` implies both gestures can be recognized. ## Actual Results In a List, only the custom gesture closure is called ("Custom gesture fired"). The button’s built-in tap action never fires ("Button action fired" is not printed). Tapping outside the text label sometimes fires the button’s action, but not the custom gesture. Essentially, the two gestures do not truly work “simultaneously.” ## Notes & Observations - This occurs consistently on iOS 16.x simulators and devices, tested as far back as iOS 15.x. - If the button is not inside a List (e.g., in a `VStack`), both gestures fire as expected. - Similar behavior occurs with NavigationLink. Adding a tap gesture on the link label inside a List breaks its navigation. ## Request Please clarify if this is intended behavior or provide a fix so that SwiftUI controls in a List can honor both their built-in tap gesture and a custom, simultaneous gesture. The current behavior contradicts the expectation set by `GestureMask.all` documentation: “Enable both the added gesture as well as all other gestures on the view and its subviews”.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at feedbackassistant.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!