I have a SwiftUI List with an HStack containing two Buttons.
If I tap either button, or elsewhere in the cell, the entire cell highlights and actions for both Buttons are fired off.
I can't find where this is documented, but have found that adding
to the List prevents this behavior - tapping individual buttons fire their individual actions as expected.
Is this an expected behavior?
Below is my example without the workaround applied:
Thanks!
If I tap either button, or elsewhere in the cell, the entire cell highlights and actions for both Buttons are fired off.
I can't find where this is documented, but have found that adding
Code Block .buttonStyle(BorderlessButtonStyle())
to the List prevents this behavior - tapping individual buttons fire their individual actions as expected.
Is this an expected behavior?
Below is my example without the workaround applied:
Code Block struct ContentView: View { var body: some View { List { HStack { Button(action: { print("button 1 tapped") }) { Text("One") } Button(action: { print("button 2 tapped") }) { Text("Two") } } } } }
Thanks!