Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIKit's present(item:content) function does not execute onDismiss #257

Open
2 of 3 tasks
acosmicflamingo opened this issue Dec 19, 2024 · 1 comment
Open
2 of 3 tasks
Labels
bug Something isn't working

Comments

@acosmicflamingo
Copy link
Contributor

Description

When using present(item:content:), the onDismiss function is not executed:

// Using item parameter
present(item: $model.destination.alert, id: \.self, onDismiss: {
  print("Yay!!!")
}) { message in
  let alert = UIAlertController(
    title: "This is an alert",
    message: message,
    preferredStyle: .alert
  )
  alert.addAction(UIAlertAction(title: "OK", style: .default))
  return alert
}

// Using isPresented parameter
present(isPresented: UIBinding($model.destination.alert), onDismiss: {
  print("Yay!!!")
}) { //message in
  let alert = UIAlertController(
    title: "This is an alert",
    message: "LOL",
    preferredStyle: .alert
  )
  alert.addAction(UIAlertAction(title: "OK", style: .default))
  return alert
}

Checklist

  • I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
  • If possible, I've reproduced the issue using the main branch of this package.
  • This issue hasn't been addressed in an existing GitHub issue or discussion.

Expected behavior

I expect that onDismiss is always executed when a presented UIAlertController is dismissed.

Actual behavior

I never see a print statement or have the debugger stop at the breakpoint in the onDismiss closure.

Steps to reproduce

If you run the CaseStudies app in this repository and go to ConciseEnumNavigation, you'll see that if you try and open an alert and then select "Ok", you cannot open it again.

SwiftUI Navigation version information

No response

Destination operating system

iOS 18.1

Xcode version information

Xcode 16.2

Swift Compiler version information

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
@acosmicflamingo acosmicflamingo added the bug Something isn't working label Dec 19, 2024
@acosmicflamingo
Copy link
Contributor Author

I created this PR with a potential fix: #255

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant