0

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

John
  • 964
  • 8
  • 21
  • Provided code works fine with Xcode 13.4 / iOS 15.5 – Asperi Jul 11 '22 at 04:47
  • @Asperi I am using Xcode 13.4.1 and iOS 15.5. The provided code fails for me both in the simulator (iPhone 13 mini) and on my iPhone. After tapping "Change List ID" the red delete buttons do not show up for the list items in edit mode. – John Jul 11 '22 at 13:25
  • Provided code works fine with Xcode 14b3 / iOS 16 as well. Are you sure you did not forget to provide anything else? – Asperi Jul 13 '22 at 18:11
  • @Asperi Yes, it does not work in a new multiplatform project without anything else added, built on a Macbook Pro with an Intel processor. I have tried a computer restart. – John Jul 15 '22 at 19:10
  • The code as is works fine with me too (new Multiplatform project, Xcode 14b3, iOS 16) – ChrisR Jul 16 '22 at 12:02
  • I have added steps to reproduce the problem. – John Jul 20 '22 at 15:19
  • @ChrisR I just tried Xcode 14 beta 3, iOS 16.0 simulator and there it works fine for me too. – John Jul 24 '22 at 22:30

0 Answers0