It gets even more strange. I removed the map functionality and just made a UIViewRepresentrable with a UILabel on it. I included a counter to verify the number of times makeUIView is called. The result was the same – multiple calls to makeUIView every other tap on the list.
I then turned to the data source for the list – a Core Data property. I use this
wrapper:
@FetchRequest(fetchRequest: Trip.getAllTrips()) var allTrips: FetchedResults<Trip>
Believe it or not, if I comment out the @FetchRequest and replace the data for the list with the following, the problem is fixed. This, of course, introduces other issues with .onDelete and more but, to me, it identifies the problem as that wrapper.
var allTrips: [Trip] {
var answer: [Trip] = []
let request: NSFetchRequest<Trip> = Trip.fetchRequest() as! NSFetchRequest<Trip>
let sortDescriptor = NSSortDescriptor(key: "name", ascending: true)
request.sortDescriptors = [sortDescriptor]
do {
let results = try managedObjectContext.fetch(request)
answer = results
} catch {
print(error)
}
return answer
}
I THINK that my issue is resolved with Xcode 13 and iOS 15 but I cannot test with my app due to another bug in the beta dealing with something about texture libraries. That seems to be a known bug.