'No fullScreenCover animation on close button

I have a strange behavior. When I close my fullScreenCover, I have no animation on it. On the other hand, I have the animation at the opening. I don't understand why I have no close animation.

Example codes

import SwiftUI

struct ContentView: View {
    
    @EnvironmentObject var myViewModel: MyViewModel

    private var gridItemLayout = [GridItem(.flexible()), GridItem(.flexible())]
    
    var body: some View {
        ScrollView {
            LazyVGrid(columns: gridItemLayout, spacing: 10) {
                ForEach(myViewModel.data, id: \.self) { data in
                    ChildView(data: data)
                }
            }
        }
        .onAppear() {
            self.myViewModel.getData()
        }
        .navigationBarTitle("My ContentView")
    }
}
import SwiftUI

struct ChildView: View {
    
    @State var data: Data
    @State var showModal = false
    
    var body: some View {
        Button(action: {
            self.showModal.toggle()
        }, label: {
            VStack {
                Text("\(data.name)")
                    .font(.body)
                    .frame(width: 180, height: 150/2, alignment: .bottom)
                
                VStack {
                    Text("\(Image(systemName: "checkmark.bubble")) 15")
                    Text("\(Image(systemName: "clock")) 20'")
                }
                .frame(width: 180, height: 150/2, alignment: .bottomTrailing)
            }
            .cornerRadius(10)
            .frame(minWidth: 0, maxWidth: 180, minHeight: 150, maxHeight: 150, alignment: .center)
        })
        .fullScreenCover(isPresented: $showModal) {
            OtherView()
        }
    }
}
import SwiftUI

struct OtherView: View {
    
    @Environment(\.presentationMode) var presentationMode
    
    var body: some View {
        NavigationView {
            VStack {
                Button {
                    presentationMode.wrappedValue.dismiss()
                } label: {
                    HStack {
                        Text("CLOSE")
                        Spacer()
                        Image(systemName: "checkmark")
                            .resizable()
                            .frame(width: 30, height: 30)
                            .padding()
                    }
                }
            }
            .navigationBarTitle("My Modal", displayMode: .inline)
        }
    }
}

Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source