Presenting View with sheet retrigger .task and .onAppear

I noticed issue on iOS 18 beta 6 .

 .sheet(isPresented: $viewModel.showingArticleSheet, content: {
                SheetView()
            })

where SheetView contain some text and a dismiss button .

I noticed that the interaction is not happen on the first click , due to view is getting reloaded , which re call .task and .onAppear at the minimum .

i have no clue how to fix that and i didn't see anyone complain of this issue .

Answered by MHegab84 in 801145022

Turn out it was a much specific issue . that i had a variable AnyCancellable. that was Published in view Model. but it should've not bee published.. still can't say why it was refreshing the whole views under it . but once i made it private and non published it solved the issue.. thanks for the help .. the idea for creating small test project was the main gate .

You should probably raise this as a bug in the usual way. It won't really get progressed if it's only posted in these Developer Forums.

You need to raise each issue you find separately at https://feedbackassistant.apple.com/ You can post the FB numbers here if you want, so that others can link to them.

@MHegab84

Do you get the same results with just the relevant code in a small test project if you test on iOS beta 7 ?

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.

Accepted Answer

Turn out it was a much specific issue . that i had a variable AnyCancellable. that was Published in view Model. but it should've not bee published.. still can't say why it was refreshing the whole views under it . but once i made it private and non published it solved the issue.. thanks for the help .. the idea for creating small test project was the main gate .

Presenting View with sheet retrigger .task and .onAppear
 
 
Q