John
John

Reputation: 1467

List Editing Breaks on ID Change

Why does list editing via the EditButton break after tapping "Change List ID"? The controls to delete list items do not appear.

Steps to reproduce:

  1. Tap "Change List ID" (do not tap "Edit" before)
  2. Tap "Edit". The delete buttons do not appear.
import SwiftUI

struct ContentView: View {
    @State var listID = UUID()
    
    var body: some View {
        Button("Change List ID", action: {
            withAnimation {
                listID = UUID()
            }
        })
        EditButton().padding(.top)
        List {
            ForEach(1..<4) {
                Text("Item \($0)")
            }.onDelete(perform: {_ in })
        }
            .id(listID)
            .transition(.slide)
    }
}

I would like to animate changing lists. I have tried a TabView with .tabViewStyle(.page) but it breaks swipe actions on list rows.

Related question: SwiftUI Edit Button not working after animation

Upvotes: 0

Views: 141

Answers (0)

Related Questions