Fullscreen Cover and Sheet Bug ? XCode 15 / iOS 17

Is anyone else able to recreate this bug in XCode 15 ?

Seems like if you use this code, the Fullscreencover or Sheet will not present / show in many of the views, I have confirmed by printing that the button is being tapped but it seems the sheet/fullscreencover will not preset for all the buttons in the horizontal scorllview.

Could anyone else see if this bug is recreated on their system?

Try tapping/clicking on some of the buttons towards the end of the Horizontal Scrollview

struct TestingBug_Previews: PreviewProvider {
    
    
    static var previews: some View {
        NavigationStack{
            ScrollView(){
                
                ScrollView(.horizontal){
                    
                    LazyHStack(
                    ){
                        
                        ForEach(1..<55, id:\.self){int in

                                   TestButton(title: num.description)
                        
                    }
                    .padding()
                }
                
            }
        }


struct TestButton: View {
    
    @State var isPresented = false
    var title: String = "No String"
    var body: some View {
        
        Button() {
            self.show_product.toggle()
            print("tapped")
        } label: {
            
            Text(title)

         
      
        }
        .sheet(isPresented: self.$isPresented, content: {
            
            Text("presented")
            
        })


        
    }
    
}

While it could be a bug, I think there's another reason. You are attaching the sheet modifier to each button instance, so in your case there could be over 50 sheets ready waiting to be shown. Instead, you could create one sheet and show it when any of the buttons are pressed. Something like this works:

struct TestButton: View {    
    @Binding var isPresented: Bool
    var title: String = "No String"

    var body: some View {
        Button {
            isPresented.toggle()
            print("tapped")
        } label: {
            Text(title)
        }
    }    
}

struct TestingBugView: View {
    @State private var isPresented = false

    var body: some View {
        NavigationStack {
            ScrollView {
                ScrollView(.horizontal) {      
                    LazyHStack {
                        ForEach(1..<55, id: \.self) { num in
                            TestButton(isPresented: $isPresented, title: num.description)
                        }
                    }
                    .padding()
                    .sheet(isPresented: $isPresented) {
                        Text("presented") 
                    }
                }       
            }
        }
    }
}

#Preview {
    TestingBugView()
}

@BabyJ I understand this solution is the typical approach but that approach makes nested views and such get messy and requires binding passing all over the show. The application of the sheet modifier on an individualised basis makes reusability much simpler rather than passing bindings everhwere, especially when nesting views.

I never noticed this as an issue in prior versions, which is why I am suddenly suprised to see it happening now.

Could anyone verify if this is expected behaviour or just a bug in the BETA ?

@BabyJ you are correct...this wasn't an issue before. I am having the same issue. Worked beautifully before the beta, in the beta it acts wonky. It is a bug and I hope they fix it.

They still haven't fixed it?

This is still an issue in iOS 17. The same code works perfectly for iOS 15/16.

Still an issue with release version of iOS 17.0

Bug still present in 17.0.2

seem this is still a bug ... run into the same problem (using @BabyJ solution) but still not working proper

I also have this issue. I did discover that if you put empty .onChange before the sheet, it works.

Button(action: {
    planActivitySheetVisible.toggle()
}, label: {
    Image(systemName: "plus")
})
// I need this for some reason to make the sheet present consistently
.onChange(of: planActivitySheetVisible) { }
.sheet(isPresented: $planActivitySheetVisible) {
    PlanActivityView( )
}

Still an issue in 17.2

Fullscreen Cover and Sheet Bug ? XCode 15 / iOS 17
 
 
Q