In the attached code, both with sections (commented lines) and without, when a row is deleted, 3 different animations occur, depending on the location of the deleted row.
Sometimes, the animation is smooth and as expected - the line just fades out. For other rows, a remaining row "jumps in" from the left side of the screen and at lastly, a remaining row "flies down" from above. The result is an unclean animation.
Has anyone seen this behavior or do I have a error in the implementation? Any suggestions?
David
Sometimes, the animation is smooth and as expected - the line just fades out. For other rows, a remaining row "jumps in" from the left side of the screen and at lastly, a remaining row "flies down" from above. The result is an unclean animation.
Has anyone seen this behavior or do I have a error in the implementation? Any suggestions?
David
Code Block import SwiftUI struct DeleteTest: View { @State private var users = [["Paul", "Taylor", "Adele", "Michael", "Courtney"], ["James", "Peter", "Paul", "Mary"], ["Hugo", "Natalie", "Heber", "Nata"]] @State private var allUsers = ["Paul", "Taylor", "Adele", "Michael", "Courtney", "James", "Peter", "Paul", "Mary", "Hugo", "Natalie", "Heber", "Nata"] var body: some View { NavigationView { List { // plain list ForEach(allUsers.indices, id: \.self) { i in NavigationLink(allUsers[i], destination: EmptyView()) } .onDelete { rowSet in allUsers.remove(at: rowSet.last!) } // grouped list // ForEach(users.indices, id: \.self) { i in // Section { // ForEach(users[i].indices, id: \.self) { j in // NavigationLink(users[i][j], destination: EmptyView()) // // Text(user) // } // .onDelete { rowSet in // self.delete(section: i, at: rowSet) // } // } // } } .listStyle(GroupedListStyle()) .navigationBarTitle("Names", displayMode: .inline) } } func delete(section: Int, at offsets: IndexSet) { users[section].remove(at: offsets.last!) } }