Xamarin.Forms icon indicating copy to clipboard operation
Xamarin.Forms copied to clipboard

[Bug] Navigation to a route relatively currently doesn't work with Shell

Open Hasanajouz opened this issue 5 years ago • 7 comments

Description

Steps to Reproduce

  1. create two flyout items for example as i created:

<FlyoutItem Route="WelcomeFlyout"> <ShellContent Route="Welcome" ContentTemplate="{DataTemplate page:WelcomePage}" /> </FlyoutItem> <FlyoutItem Route="RegisterFlyout"> <ShellContent Route="Register" ContentTemplate="{DataTemplate page:RegisterPage}" /> </FlyoutItem> 2. from first shellcontent page try to: Shell.Current.GoToAsync("Register",false); it will give Timeout exceeded exception in main,cs

Expected Behavior

as it was in all pre-releases<10 it should navigate to the register page

Actual Behavior

exception

Basic Information

  • Version with issue: pre 10 Last known good version: pre 9
  • IDE: vs2019 for windows
  • It happenes for both:
    • iOS
    • Android

Hasanajouz avatar May 05 '19 11:05 Hasanajouz

@Hasanajouz I wasn't able to trigger this with a timeout exception. Currently we don't support relative routing to other routes because shell doesn't currently support a navigation stack for routes.

If you change the navigation to

Shell.Current.GoToAsync("Register",false); 

does that work?

PureWeen avatar May 05 '19 16:05 PureWeen

Shell.Current.GoToAsync("Register",false); is exactly what i tried.

I used to route between other routes without navigation. so If i have two flyout itmes and i want to go to one of them from the other flyout what should i do now?

while Shell.Current.GoToAsync("Register",false); used to work in pre 9

Hasanajouz avatar May 05 '19 17:05 Hasanajouz

@Hasanajouz wait I copy and pasted the wrong sample apologies

Can you try

Shell.Current.GoToAsync("//Register",false); 

PureWeen avatar May 05 '19 17:05 PureWeen

@PureWeen yes that worked Thanks so much. If you can just give me a link to know where should I use // or / or nothing?

Hasanajouz avatar May 05 '19 17:05 Hasanajouz

@Hasanajouz Awesome!! Here's the initial spec for how that all works

https://github.com/xamarin/Xamarin.Forms/issues/5790

We're still getting the behavior for pushing routes on to the stack all finished though. The syntax you initially have will work in upcoming versions

PureWeen avatar May 05 '19 17:05 PureWeen

Given the 4.2 RC releases, can we expect this as part of 4.3+?

dlakes-hx avatar Aug 01 '19 16:08 dlakes-hx

Follow up question @PureWeen -- since routes aren't pushed on to the stack at this time, what is the suggested approach for back button behavior? Do Shell apps need to maintain their own internal queue by hooking in to Shell.OnNavigated that can be popped as needed?

Currently in our application when attempting to invoke default back button behavior, the application crashes. I'm fairly certain all of the routes are being correctly defined (mix of Xaml and RegisterRoute), and invoked via GoToAsync or visual navigation. All of the documentation, ex: here, seems to suggest default back behavior just works. However, some of the comments in doc issues, ex MicrosoftDocs/xamarin-docs#1401, suggest that's not necessarily the case.

At this point, I'm unclear if this is an issue with our application, an issue with documentation, a framework issue, or some mix of the three.

dlakes-hx avatar Aug 26 '19 16:08 dlakes-hx