1

SwiftUI list rown and buttons in same section in edit mode do not allow actions

Goal Would like to have clickable buttons in list and section, movable and deletable rows in list

code:

Section(header: Text("HEADER")) {
  List {
    ForEach(dataList) { data in
      Button {
        // action will not be called
        print("action will not be called")
      } label: {
        Text("Button in list")
      } // Button
    } // ForEach
      .onMove(perform: onMove)
  } // List

  Button {
    // action will not be called
    print("action will not be called")
  } label: {
    Text("Button in section")
  }

} // Section
// .environment(\.editMode, .constant(.active))
Daniil
  • 61
  • 2
  • 1
    Does this answer your question https://stackoverflow.com/a/60964567/12299030? Or this one https://stackoverflow.com/a/61813896/12299030? – Asperi Feb 01 '22 at 17:08
  • @Asperi unfortunately, the onTapGesture is only triggered if I tap the button text :( – Daniil Feb 01 '22 at 17:11

0 Answers0