`.navigationDestination` wrapper for enum cases doesn't appear to do anything
gmedori opened this issue · 1 comments
Description
I just started using this library for the first time after having watched the Modern SwiftUI series on pointfree.co and it looks like the .navigationDestination
modifier isn't navigating to the intended view. The .sheet
modifier works as expected though.
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 expected a parent view to navigate to a detail view within a navigation stack.
Actual behavior
It didn't do anything.
Steps to reproduce
I've thrown together a sample project illustrating this issue. Hopefully this captures the behavior you need.
NavigationDestinationBusted.zip
SwiftUI Navigation version information
1.0.2
Destination operating system
iOS 17
Xcode version information
Version 15.0 (15A240d)
Swift Compiler version information
swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
Target: arm64-apple-macosx14.0
@gposcidonio Your sample project has the navigationDestination
view modifier applied outside the NavigationStack
view, which prevents it from working (same goes for the vanilla modifier that comes with SwiftUI). Moving navigationDestination
into the NavigationStack
fixes things, though we should note that navigationDestination
has had a buggy history in vanilla SwiftUI, and so you may want to look out for those bugs and file feedback with Apple if you encounter them.
I'm going to convert this to a discussion since it's not a bug in the library.