You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! First of all, I'm sorry if it's a stupid question or if it has nothing to do with these package.
I'm trying to animate a List where the order of elements depends on a variable in Defaults.
If I'm using a @State, it's working as expected.
If I'm using a @Default, animation doesn't work.
These works:
enumOrderBy:String,Codable,Defaults.Serializable{case index, name
}structElement:Identifiable{letid:Stringletindex:Intletname:String}letallElements:[Element]=[.init(id:"1", index:5, name:"Element 1"),.init(id:"2", index:4, name:"Element 2"),.init(id:"3", index:1, name:"Element 3"),.init(id:"4", index:3, name:"Element 4"),.init(id:"5", index:2, name:"Element 5"),]structMyView:View{@Statevarorder:OrderBy=.index
func toggleOrder(){withAnimation{
order = order ==.index ?.name :.index
}}varelements:[Element]{
allElements.sorted(by:{ order ==.index ? $0.index < $1.index : $0.name < $1.name })}varbody:someView{Picker("Order by", selection: $order){Text("index").tag(OrderBy.index)Text("name").tag(OrderBy.name)}List{ForEach(elements, id: \.id){ element inText("Element \(element.name)")}}}}
Is there any way we can bypass the issue without an intermediate variables somewhere?
Will it be fixed in the package or when the SwiftUI bug will be fixed?
Thanks!
Hi @sindresorhus! Any idea when this issue with animation could be fixed?
Is there something we can do to work around this issue by having an intermediate storage for example?
Activity
sindresorhus commentedon Nov 29, 2024
Most likely a SwiftUI bug. The issue was introduced by 2dad0e4, but that was done to work around another SwiftUI bug, so we cannot just revert that.
Vincz commentedon Dec 11, 2024
Is there any way we can bypass the issue without an intermediate variables somewhere?
Will it be fixed in the package or when the SwiftUI bug will be fixed?
Thanks!
richardkunkli commentedon Jan 21, 2025
Hi! Any update on this specific issue? Faced the same with version 9.0.1.
Vincz commentedon Jun 5, 2025
Hi @sindresorhus! Any idea when this issue with animation could be fixed?
Is there something we can do to work around this issue by having an intermediate storage for example?
sindresorhus commentedon Jun 6, 2025
I haven't looked into yet, and I don't plan to until I know whether macOS 16 (or 26) fixes it.