title: IndexSet referring to index of the section instead of the row
body: <p>I want to implement a swipe-to-delete functionality on a SwiftUI <code>Section</code> by using the <code>.onDelete</code> modifier. The problem is that it always deletes the first item in the list.</p>
  
  <p>My view has a list with dynamic sections created with a <code>ForEach</code>.</p>
  
  <pre><code>struct SetListView : View {
  
      var setlist: Setlist
      var body : some View {
  
          List { 
              ForEach(setlist.sets) { 
                   SetSection(number: $0.id, songs: $0.songs) 
              }
          }
          .listStyle(.grouped)
      }
  }
  </code></pre>
  
  <p>In each section, there is another <code>ForEach</code> to create the dynamic rows:</p>
  
  <pre><code>private struct SetSection : View {
  
      var number: Int
      @State var songs: [Song]
  
      var body : some View {
          Section (header: Text("Set \(number)"), footer: Spacer()) {
              ForEach(songs) { song in
                  SongRow(song: song)
              }
              .onDelete { index in
                  self.songs.remove(at: index.first!)
              }
          }
      }
  }
  </code></pre>
  
  <p>While debugging, I found out that the <code>IndexSet</code> is referring to the current section instead of the row. So when deleting items from the first section, always the first item gets deleted (as the index for the first section is 0).</p>
  
  <p>Is this a bug in SwiftUI? </p>
  
  <p>If not, then how could I get the index for the row?</p>