Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

[Bug] Xamarin.Forms Shell - contextual navigation from global routes is not working #11237

Closed
MaxFmi opened this issue Jun 29, 2020 · 6 comments · Fixed by #13330
Closed

[Bug] Xamarin.Forms Shell - contextual navigation from global routes is not working #11237

MaxFmi opened this issue Jun 29, 2020 · 6 comments · Fixed by #13330

Comments

@MaxFmi
Copy link

MaxFmi commented Jun 29, 2020

Description

Having two pages registered as global routes (see "Register page routes" under Shell navigation) and navigating in a contextual way won't work (nothing happens, no exception, no return value or anything else).

Steps to Reproduce

  1. Open the provided example -> Xaminals global routes contextual navigation.zip
  2. Open it in your IDE.
  3. Open the file Xaminals.ViewModels.MonkeyDetailViewModel.cs.
  4. Add a breakpoint at line 49.
  5. Start the app and navigate to
    5.1 Monkeys (tab)
    5.2 Select any monkey
    5.3 Click the button "Navigate to MonkeyGenomePage"

Expected Behavior

App should navigate to the page MonkeyGenomePage.

Actual Behavior

Nothing happens.

Basic Information

  • Version with issue: Xamarin.Forms 4.7.0.968
  • Last known good version: -
  • IDE: Visual Studio for Mac 8.5
  • Platform Target Frameworks:
    • iOS: Simulator 13.5
    • Android: 9.0
  • Android Support Library Version: 28.0.03

Screenshots

Reproduction Link

Workaround

Not using contextual routes on global routes + using a prefix to make routes unique.

@MaxFmi MaxFmi added s/unverified New report that has yet to be verified t/bug 🐛 labels Jun 29, 2020
@pauldipietro pauldipietro added this to New in Triage Jun 29, 2020
@MaxFmi MaxFmi changed the title [Bug] Xamarin.Forms Shell - contextual navigation from global routes results in an exception [Bug] Xamarin.Forms Shell - contextual navigation from global routes not working Jun 29, 2020
@MaxFmi MaxFmi changed the title [Bug] Xamarin.Forms Shell - contextual navigation from global routes not working [Bug] Xamarin.Forms Shell - contextual navigation from global routes is not working Jun 29, 2020
@PureWeen PureWeen added this to Backlog in Shell via automation Jul 2, 2020
@PureWeen PureWeen removed the s/unverified New report that has yet to be verified label Jul 2, 2020
@PureWeen PureWeen moved this from New to Ready For Work in Triage Jul 2, 2020
@samhouts samhouts moved this from Ready For Work to Needs Estimate in Triage Jul 2, 2020
@samhouts samhouts added this to the 5.0.0 milestone Aug 13, 2020
@samhouts samhouts added this to To do in vNext+1 (5.0.0) Aug 13, 2020
@samhouts samhouts removed this from the 5.0.0 milestone Nov 2, 2020
@tcerdaj
Copy link

tcerdaj commented Dec 4, 2020

I got the same issue in Xamarin forms 4.8.

@RidhwanDev
Copy link

RidhwanDev commented Dec 24, 2020

Yes same here, any work around for this? I need to keep state of 3 pages intact when navigating between them. I'm also not using the tabs because I'm rendering my own tabs.

The main tab is supposed to act as the initial page, I want to navigate between the two other pages like "../page1" and "../page2". And to navigate back to the main page "..". This doesn't work when trying to go to the main page and when trying to navigate to the other pages it throws exception
System.ArgumentException: 'unable to figure out route for: //IMPL_BoyNamesPage/IMPL_BoyNamesPage/GirlNamesPage
Parameter name: uri'

@PureWeen
Copy link
Contributor

PureWeen commented Jan 9, 2021

@MaxFmi @tcerdaj @RidhwanDev

Can you test with the nuget here?
https://dev.azure.com/xamarin/public/_build/results?buildId=33354&view=artifacts&pathAsName=false&type=publishedArtifacts

@MaxFmi a couple notes about the sample you attached

  1. On monkey view model where you have the code that goes to monkeyDetails absolutely your casing on monkeydetails is wrong and should be monkeyDetails
  2. The better way to go back twice here is to use await Shell.Current.GoToAsync("../..");. the problem with using RemovePage is that it now makes the uri invalid since the monkeygenome page depends on the monkeyDetails page to be there in order to for a valid uri. I'm not too sure the best way to handle this case. I'm thinking throwing an exception would probably be the best bet so that users aren't met with weird behavior.

@PureWeen PureWeen moved this from Backlog to In Progress in Shell Jan 9, 2021
@PureWeen PureWeen moved this from In Progress to In Review in Shell Jan 9, 2021
@PureWeen PureWeen moved this from Needs Estimate to Ready For Work in Triage Jan 9, 2021
@MaxFmi
Copy link
Author

MaxFmi commented Jan 12, 2021

@PureWeen Thanks for the answer.

I haven't worked with Azure DevOps and am not sure where to download the nuget. Artifacts is only showing two old Android entries.
Screenshot 2021-01-12 at 14 17 06
Screenshot 2021-01-12 at 14 17 51
Screenshot 2021-01-12 at 14 14 26

Addressing 1. Corrected spelling and uploaded example in this issue.
Addressing 2. Prior to Xamarin.Forms 5 "await Shell.Current.GoToAsync("../..");" had no animation so we couldn't use it in our app. Using it now in this example.

@PureWeen
Copy link
Contributor

@MaxFmi on the page above you would click on where it says "4 published"

Here's a direct link you can use
https://dev.azure.com/xamarin/public/_build/results?buildId=33354&view=artifacts&pathAsName=false&type=publishedArtifacts

When you hover over the "nuget" option you'll see three dots to the right. Click those to download the packages

@Redth Redth moved this from Ready For Work to Needs Estimate in Triage Jan 13, 2021
@PureWeen PureWeen added the e/7 🕖 7 label Jan 13, 2021
@PureWeen PureWeen moved this from Needs Estimate to Ready For Work in Triage Jan 13, 2021
Triage automation moved this from Ready For Work to Closed Jan 15, 2021
Shell automation moved this from In Review to Done Jan 15, 2021
rmarinho pushed a commit that referenced this issue Jan 15, 2021
fixes #13328 fixes #11237

* Fix Shell Navigation for Hierarchally registered Global Routes

* - fix added paths

* - fix relative hierarchical routing

* - remove extra comment

* - remove comments

* - generalize shell setter

* - additional test

* Update BaseShellItem.cs

* - fix routes pushed with longer uris

* - improve matching

* - clean up comments

* - fix multiple back navigation with hierarchies

* - fix root routes

* - fix absolute routes
@MaxFmi
Copy link
Author

MaxFmi commented Jul 15, 2022

It works. Thank you @PureWeen

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Shell
  
Done
Triage
  
Closed
Development

Successfully merging a pull request may close this issue.

6 participants