[iOS 18.2 Beta] LazyVGrid within NavigationStack breaks animations

Hello. There seems to be a bug specifically in the iOS 18.2 (both Beta 1 and 2) and not seen in the previous versions.

The bug is: when LazyVGrid is nested inside NavigationStack and some elements of the LazyVGrid have animations, navigating into any nested view and then going back to the initial view with the LazyVGrid causes all animations to stop working.

Here is the example code inline:

struct ContentView: View {
    @State private var count: Int = 0
    
    var body: some View {
        NavigationStack {
            LazyVGrid(
                columns: Array(
                    repeating: GridItem(spacing: 0),
                    count: 1
                ),
                alignment: .center,
                spacing: 0
            ) {
                VStack {
                    Text(String(count))
                        .font(.system(size: 100, weight: .black))
                        .contentTransition(.numericText())
                        .animation(.bouncy(duration: 1), value: count)
                    
                    Button("Increment") {
                        count += 1
                    }
                    
                    NavigationLink(destination: { Text("Test") }, label: { Text("Navigate") })
                }
                
            }
        }
        .padding()
    }
}

Once you run the application on iOS 18.2 Beta (I've tried on a real device only), the steps to reproduce are:

  1. Tap on the "Increment button"
  2. You should see the number change with an animation
  3. Tap on the "Navigate" button
  4. Tap "Back" to go to the initial screen
  5. Tap "Increment" again
  6. The number changes without an animation

I can confirm that this affects not only .contentTransition() animation but any animation within the LazyVGrid, I've tested this in my real app.

Let me know if I can provide more details. Thank you!

Answered by nik-harmash in 818874022

Ok, just tested on iOS 18.3 Beta 1 and everything seems to work as expected 🎉 Thank you to whoever was the person fixing this!

I just tried on iOS 18.2 Beta 3 and the bug is still present.

Have the same issue on my app. Can Apple comfirm this is an bug?

I have filed a feedback (FB15897883), hope someone from Apple will take a look at this issue.

Unfortunately, the bug is still present in iOS 18.2 Beta 4

I'm having the exact same issue, but thought I had just made a mistake!

The bug is still present in iOS 18.2 RC 😔 I guess we need to come up with a workaround, I'll probably try some alternative layout scheme instead of LazyVGrid

Accepted Answer

Ok, just tested on iOS 18.3 Beta 1 and everything seems to work as expected 🎉 Thank you to whoever was the person fixing this!

[iOS 18.2 Beta] LazyVGrid within NavigationStack breaks animations
 
 
Q