Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[XF] CreateTab and SelectedTab not supported in NavigationParameters class #1391

Closed
JunkyXL86 opened this issue Mar 12, 2018 · 4 comments
Closed

Comments

@JunkyXL86
Copy link

JunkyXL86 commented Mar 12, 2018

Description

I created a small sample solution using the latest NuGet version of Prism.Forms 7.0.0.396 that reproduces the bug(s).
Navigating to a TabbedPage using NavigationParameters to create and select a tab does not really work unless you specify the parameters within the query string. If you use the overload with the NavigationParameters param, they are not respected or it even fails with a NullReferenceException.

Steps to Reproduce

The parameters ->

var parameters = new NavigationParameters();
parameters.Add(KnownNavigationParameters.CreateTab, nameof(PageA));
parameters.Add(KnownNavigationParameters.CreateTab, nameof(PageB));
parameters.Add(KnownNavigationParameters.SelectedTab, nameof(PageB));

Navigation ->

// Nothing happens
NavigationService.NavigateAsync("TabbedPage", parameters);
// Works as expected
NavigationService.NavigateAsync("TabbedPage" + parameters);

Note the '+' which concatenates the parameters to an entire query string.
Whereas the first approach using the parameter overload does not work.

Using a more complex scenario it even throws an exception:

// throws NullReferenceException
NavigationService.NavigateAsync("MyMasterDetailPage/NavigationPage/TabbedPage", parameters);

Just using the query string works:

// Works as expected
NavigationService.NavigateAsync("MyMasterDetailPage/NavigationPage/TabbedPage" + parameters);

Expected Behavior

Exact same navigation behavior like using parameters within the query string.

Actual Behavior

Navigation parameters in query string are treated differently.

Basic Information

  • Version with issue: Prism.Forms 7.0.0.396
  • Last known good version: -
  • Xamarin.Forms version: 2.5.0.122203
  • IDE: Visual Studio 2017 (15.5.6)

Reproduction Sample

NavParams.zip

@brianlagunas
Copy link
Member

Yes, I am aware of this. As of now, this is how the feature was designed. I will have to discuss with the team if we want to change how this works and support the NavigationParameters class too.

@brianlagunas brianlagunas changed the title Prism.Forms NavigationParameters object not working on navigation [XF] CreateTab and SelectedTab not working in NavigationParameters class Mar 12, 2018
@brianlagunas brianlagunas changed the title [XF] CreateTab and SelectedTab not working in NavigationParameters class [XF] CreateTab and SelectedTab not supported in NavigationParameters class Mar 12, 2018
@brianlagunas
Copy link
Member

brianlagunas commented Sep 21, 2018

I have a couple of concerns about implementing this. First, there would be an immediate limitation of not being able to deep link into an app that has multiple TabbedPages. This is because both TabbedPages would read the NavParams class and create tabs based on those values. This could be very bad, and there is no way to control it. Another problem is the amount of code churn and logic that would need to be added to the NavigationService to support this.

The safest and most reliable way to do this would be to keep it in the query string. However, if there is an overwhelming request from the community, we can add it, but will have to note the known limitation which many people won't know about until they actually run into the problem and open an issue here :)

Thoughts?

@brianlagunas
Copy link
Member

After thinking about this more, I have decided not to suppor this for the reasons I outline in my previous comment. However, you can still use the NavigationParameters class if you like, you just have to provide them inline in the URI like you outlined in your example.

@lock
Copy link

lock bot commented Jan 29, 2020

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants