popup window don't react to touch on iOS 18, works fine on iOS 17

popup window don't react to touch on iOS 18, works fine on iOS 17, this is the code: import SwiftUI

extension View { public func popup<Content, Item>( item: Binding<Item?>, onDismiss: (() -> Void)? = nil, @ViewBuilder content: @escaping (Item) -> Content ) -> some View where Content: View, Item: Equatable { return self.overlay( PopupWrapper(item: item, onDismiss: onDismiss, content: content) ) } }

struct PopupWrapper<Content, Item>: View where Content: View, Item: Equatable { @Binding var item: Item? var onDismiss: (() -> Void)? var content: (Item) -> Content @State var isAnimating = false

var body: some View {
    Group {
        if let item {
            ZStack {
                Color.black
                    .opacity(0.3)
                    .ignoresSafeArea()
                    .contentShape(Rectangle())
                    .gesture(
                        TapGesture().onEnded {
                            withAnimation(.spring(duration: 0.2)) {
                                isAnimating = false
                                DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
                                    dismiss()
                                }
                            }
                        }
                    )

                content(item)
                    .scaleEffect(isAnimating ? 1 : 0.3)
                    .opacity(isAnimating ? 1 : 0)
                    .onAppear {
                        withAnimation(.spring(duration: 0.3)) {
                            isAnimating = true
                        }
                    }
                    .gesture(
                        TapGesture().onEnded {
                            withAnimation(.spring(duration: 0.2)) {
                                isAnimating = false
                                DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
                                    dismiss()
                                }
                            }
                        }
                    )
                    .onDisappear {
                        dismiss()
                    }
            }
        } else {
            EmptyView()
        }
    }
}

func dismiss() {
    item = nil
    isAnimating = false
    onDismiss?()
}

}

Please format your code properly in future. Once you submit your post, take a look and make sure it looks fine. If it doesn't, you have an hour to edit the post. Right now, the gobbledegook at the top is difficult to understand.

Do you get the same results with just the relevant code in a small test project? If so, please share a link to your test project. That'll help us better understand what's going on. If you're not familiar with preparing a test project, take a look at Creating a test project.

popup window don't react to touch on iOS 18, works fine on iOS 17
 
 
Q