Issues/Confusion with Complex Relative Shell Navigation Routes #14771
Replies: 4 comments 1 reply
-
For number 6, I implemented this as a workaround public Task NavigateToCurrentRoot()
{
string path = Shell.Current?.CurrentState.Location.ToString();
string root = path.Split("/", StringSplitOptions.RemoveEmptyEntries)[0];
return NavigateTo("///" + root);
} |
Beta Was this translation helpful? Give feedback.
-
IMHO, Shell is like a TabbedPage, with a navigation stack tacked on. I thnk it holds TWO kinds of information: the tab that is showing, plus a navigation stack for "go back". I can't comment on its design decisions, or how it might be improved, but I've used it enough to address some of your confusion about how it works.
"upward" seems to first search for a (sibling) entry in current page's parent. Better description might be "first path element must be sibling of current page or sibling of an ancestor". By "first path element", I mean "choice/more" would look for "choice" in those places. Then would look for "more" child of "choice".
The root isn't a page. Its AppShell itself. You have to tell it what root page (tab) you want to display. Alternatively, Shell could remember which tab you were displaying last, and pop back to that tab
The issue here is the part of "///" that does "The matching page will REPLACE the navigation stack." Refer back to the beginning of this comment. The problem is that there isn't ONLY a nav stack. There also has to be a current root tab to "go back" to. Routing hides this limitation. Perhaps this could be changed so that it acted exactly like "/choice" in your case. [By "implicitly", I mean that "inspect" isn't stored on the stack. Its held elsewhere. If you examine the actual nav stack, it will only have one page on it, "inspect/choice". If you pop that, the internal stack is empty.] But "/choice" already does that, so don't need "///choice" to do the same |
Beta Was this translation helpful? Give feedback.
-
hey have you gotten an answer to this? It seems to me that there is no functional difference between GoToAsync("**/**page") v.s. GoToAsync("page"). |
Beta Was this translation helpful? Give feedback.
-
Sorry, I'm confused how does it help? GoToAsync seems to always push a new page onto the stack, it doesn't seem like the contents of the hierarchy makes a difference for that. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Referencing this, which has imo a more helpful explanation of routes than the official docs has.
The app I'm developing has a huge hierarchy of pages:
The visual hierarchy:
And then a series of non-visual sub and sub-sub pages:
I try to do all routing relatively, unless there's a specific "go back to the beginning" need so I use three slashes.
I definitely have had issues with routing from one page to another and it seems like I'm consistently doing something wrong/misunderstanding/seems like something is missing from how I have this set up. The leading slashes also sometimes seem kind of arbitrary? I get a lot of 'cant figure out route' or 'ambiguous route' errors, for things where I'm simply trying to navigate to a descendant route.
The first example
... is kind of just some weirdness I've encountered:
If let's say I'm on route
assign
. A function on the page wants to bring you to another page, so IGoToAsync("choice", [args])
. That works, but I dont think it should. The documentation says navigating to a route that does not start with a slash means we navigate UP the hierarchy (I'm interpreting UP as meaning toward root. Also UP/DOWN not a clearly explained concept in the docs), how could it possibly be finding the correct page to navigate to by moving UP? If I useGoToAsync("/choice", [args])
, it also works, more in the way I'd expect. //choice makes an error "unable to figure out route for: //choice (Parameter 'uri')", and ///choiceJust to summarize, my current route is a shell route,
assign
and the result of navigating to...choice
works, but not sure why/choice
works//choice
fails, "unable to figure out route for: //choice (Parameter 'uri')". Reasonable, it's not a root route///choice
fails, "unable to figure out route for: ///choice (Parameter 'uri')". This should work, if the documentation is to be believed.The second example
... is more a physical constraint with navigation that I can't seem to work around. Its also a bit more esoteric:
All of the pages in the Picking FlyoutItem [totes, assign, picking, inspect] (except pickQa) share a common functionality. There is a series of screens that runs to change the status of the underlying objects. This works by having two pages that sort of chain execution and walk the user through a specific flow,
selectCart
followed byselectCart/moveTotes
.//inspect
which is a root/visual hierarchy route.GoToAsync("/inspect", [args])
. I'm now at//inspect/pickticket
.GoToAsync("/selectCart",[args])
. So far so good. I'm now at//inspect/pickTicket/selectCart
. Wait a sec, how did that happen? The route for the page I want is atselectCart
, how is this working?GoToAsync("/moveTotes",[args])
. I'm now at//inspect/pickTicket/selectCart/moveTotes
and interact there for a bit.GoToAsync("../../../")
which sends me back to//inspect
. My intention is that the navigation stack resets at this point, because the process is finished and there is no way to really "go back" once you finish. Usually you do this by navigating to ///route.Apart from the weirdness with selectCart/moveTotes, this is good and working.
Here's where the problem comes in. I'm hard coding ../../../ but really I need some way to go back to the ShellContent root route, whatever it is, but I don't know what it is. I can wind up in the selectCart/moveTotes workflow from any of the other screens; and with an arbitrary nesting level, and ../../../ wouldn't work. (Example;
picking/selectCart/moveTotes
). Basically what I want is to return to///inspect
or///picking
(or others) from moveTote, without having to have moveTote know where it is. Is that possible?Taking it one step further...
The routes I have listed above were the closest thing I could come up with that works almost right.
What I attempted at first, made logical sense to me. Just make a route for selectCart in each path where it was possible.
This seemed clean, but I couldn't get it to work at all, because no matter how I tried to relatively navigate to selectCart it told me it was always an ambiguous route.
It also has the same problem of not being able to escape back to the root in any simple way. I would love to see navigation to "///" be an option to go back to the ShellContent page and clear the history stack.
Summary
Beta Was this translation helpful? Give feedback.
All reactions