Closed okla closed 1 year ago
Using a workaround for now
List {
ForEach($items) { ... }
.onMove {
items.move(fromOffsets: $0, toOffset: $1)
}
}
@okla Can you provide a full reproduction of the original issue you were having for us to work with? Right now we don't really have much to go off of. We do have a test for move(fromOffsets:toOffset:)
, though:
@stephencelis Here's the full reproduction code
import SwiftUI
import IdentifiedCollections
struct Item: Identifiable {
var id = UUID()
}
struct ContentView: View {
@State var items: IdentifiedArray = [Item(), Item(), Item()]
var body: some View {
List($items, editActions: .all) { item in
Text("\(item.wrappedValue.id)")
}
}
}
@main
struct testApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
@okla Thanks! Can you try this PR's branch and see if it fixes the issue for you?
https://github.com/pointfreeco/swift-identified-collections/pull/48
@stephencelis Works fine now!
I'm using
var items: IdentifiedArrayOf<MyType>
with SwiftUI'sList($items, editActions: .all)
and once I rearrange any element in the list the app crashes withPrecondition failed: Element identity must remain constant