Closed thompsondave closed 1 year ago
Hi @thompsondave, you are missing one piece from using the presentation tools: you must use ifLet
to integrate the child feature behavior with the parent. This goes even for alerts, which don't really have much logic or behavior other than the fact that when you tap any button in an alert the state should be immediately cleared out.
So you just need this:
Reduce { state, action in
}
.ifLet(\.$alert, action: /Action.alert)
Since this isn't an issue with the library I am going to convert it to a discussion. Feel free to continue the conversation there.
Description
When using @PresentationState to display an alert with a
ButtonState(role: .cancel)
if you tap on the cancel button to dismiss the alert it is dismissed, but then try to navigate somewhere else e.g tap a button to show a fullScreenCover, the alert is presented again and the navigation to fullScreenCover fails. The reduce is then no longer able to display the fullScreenCover.The workaround for this is to always explicitly handle .alert(.dismiss) and set state.alert = nil
Checklist
main
branch of this package.Expected behavior
After dismissing the alert with ButtonState(role: .cancel) we should be able to navigate to a fullScreenCover without the alert state being shown again.
Actual behavior
After dismissing the alert with ButtonState(role: .cancel), attempting to navigate to a fullScreenCover shows the alert state again.
https://github.com/pointfreeco/swift-composable-architecture/assets/39087142/24c0d2a6-fd15-4c5b-a050-4b98b69821e9
Steps to reproduce
Attached minimal project: TestComposableArchitecture.zip
The Composable Architecture version information
ea631ce892687f5432a833312292b80db238186a
Destination operating system
iOS 16
Xcode version information
XCode 14.3.1
Swift Compiler version information