@brebispanique @sjb_s thank you both for quick answers.
My app doesn't use a NavigationPath but a custom enum that conforms to Hashable with possible paths. And I can still reproduce this issue in a simple test app with two views when try to push a second view into the NavigationStack.
enum RouterDestination: Hashable {
case next
}
Post
Replies
Boosts
Views
Activity
@brebispanique @sjb_s the code that still doesn't work is here: https://developer.apple.com/forums/thread/760041
@dderg thank you for your feedback.
It also isn't fixed on my side and I also use path as a @Published variable in an ObservableObject.
Do you use a custom path or type-erased NavigationPath?
@sjb_s Thank you for your code. I found the reason for the issue.
If I embed navigationDestination into the View extension (as it is in my real app), then the issue can be reproduced.
extension View {
func withAppRouter() -> some View {
navigationDestination(for: Item.self) { item in
DetailView(item: item)
}
}
}
I have a centralised routing system and a single extension where all routes are located.
@DTS Engineer can you help here please?
@brebispanique it doesn't fix the issue, unfortunately, but changes it.
In my code sample, it works well with NavigationPath only if you push the next screen the first time.
But please press the Back button and then press "Next" again. Everything seems to be ok with animation but now you will need to press the Back button two times to return back to the initial screen.
Please press "Next" again after that. You will need to press the Back button three times to return back to the initial screen.