-
Notifications
You must be signed in to change notification settings - Fork 172
.destination(.dismiss) not called if using @ReducerCaseIgnored with Identifiable model in UIKit #291
Description
Description
When using @ReducerCaseIgnored with a model that conforms to Identifiable, the .destination(.dismiss) action is not triggered when the view controller is dismissed.
struct IdentifiableModel: Identifiable, Equatable {
let id: String
}
struct NotIdentifiableModel: Equatable {
let id: String
}
…
@Reducer
enum Destination {
@ReducerCaseIgnored
case identifiable(IdentifiableModel)
@ReducerCaseIgnored
case notIdentifiable(NotIdentifiableModel)
}
…
// Does _not_ trigger `.destination(.dismiss)` when `IdentifiableModelViewController` is dismissed.
present(
item: $store.scope(state: \.destination?.identifiable, action: \.destination.identifiable)
) { store in
IdentifiableModelViewController(identifiableModel: store.withState { $0 })
}
// _Does_ trigger `.destination(.dismiss)` when `NotIdentifiableModelViewController` is dismissed.
present(
item: $store.scope(state: \.destination?.notIdentifiable, action: \.destination.notIdentifiable)
) { store in
NotIdentifiableModelViewController(notIdentifiableModel: store.withState { $0 })
}From my debugging with breakpoints, it appears that this line evaluates to true (both nil) if the model is not Identifiable, and false when the model is Identifiable (id is nil while _identifiableID(childState) is set from the model's id).
This is within the swift-composable-architecture repository, but since the issue seems to be related to navigation behavior, I’ve filed the issue here.
Checklist
- I have determined whether this bug is also reproducible in a vanilla SwiftUI project.
- If possible, I've reproduced the issue using the
mainbranch of this package. - This issue hasn't been addressed in an existing GitHub issue or discussion.
Expected behavior
The .destination(.dismiss) action should be called, and destination should be set to nil.
Actual behavior
The .destination(.dismiss) action is not called.
Steps to reproduce
You can reproduce the issue using this repository/file.
SwiftUI Navigation version information
2.3.1
Destination operating system
iOS 18.5
Xcode version information
16.2 (16C5032a)
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)
Target: arm64-apple-macosx15.0