How to 'intercept' NavigationLink push? #38
Replies: 4 comments
-
|
The first problem is a misunderstanding of onNavigationReceive and its intended purpose. it's not a general-purpose "onNavigation" notification handler. Its sole purpose is to receive values sent by Second, and as mentioned in the documentation, NavigationLink(value:) will always push. That's its job. (A job reinforced, I might add, by the chevrons and visual indicators added when using it.) |
Beta Was this translation helpful? Give feedback.
-
|
Okay, thanks for the quick response! Maybe instead of showing my botched solution, telling what I actually want might be easier.
How would I go about doing that? |
Beta Was this translation helpful? Give feedback.
-
|
Getting outside the scope of Navigator. The classic NavigationSplitView uses a binding to show the content view. You'd need some code to do the check and then do the right thing. You can't use NavigationLink(value:) (or any NavigationLink, for that matter) as it will always push and that push can't be cancelled. |
Beta Was this translation helpful? Give feedback.
-
|
Alright, thanks |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using a
NavigationSplitView, where the buttons in the sidebar areNavigationLinks. I can't really use anything else as seemingly onlyNavigationLinkdoes things like coloring the background of the active category. There is however a problem, becauseNavigationLinkalways pushes, it seems that this means it also bypasses things like.onNavigationReceive.A quick illustration of the code I have with the question being, how can I make this actually work.
Beta Was this translation helpful? Give feedback.
All reactions