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

[Navigation] Page stack support when using Region.Attached="True" #2604

Open
1 task done
eriklimakc opened this issue Nov 6, 2024 · 2 comments
Open
1 task done
Assignees
Labels
kind/bug Something isn't working

Comments

@eriklimakc
Copy link
Contributor

eriklimakc commented Nov 6, 2024

Current behavior

In a typical navigation flow with Uno.Extensions.Navigation, where MainPage is a standard page (without NavigationView or TabBar), navigating to SecondPage successfully builds a navigation stack. This allows returning to MainPage without needing to specify a DependsOn: "Main" in SecondPage's RouteMap.

However, when using NavigationView or TabBar in MainPage, along with a <Grid uen:Region.Attached="True" uen:Region.Navigator="Visibility" /> to render pages, specifying DependsOn in the RouteMap becomes necessary to maintain the page stack and enable back navigation.

So if we have a page that can be navigated to from multiple pages, defining multiple RouteMaps for that page becomes necessary.

Expected behavior

How to reproduce it (as minimally and precisely as possible)

Environment

Nuget Package (s):

Package Version(s):

Affected platform(s):

  • All
@eriklimakc eriklimakc added kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification. labels Nov 6, 2024
@eriklimakc
Copy link
Contributor Author

Repro2604.zip

@eriklimakc eriklimakc self-assigned this Nov 20, 2024
@kazo0 kazo0 removed the triage/untriaged Indicates an issue requires triaging or verification. label Jan 7, 2025
@kazo0
Copy link
Contributor

kazo0 commented Jan 22, 2025

Problem was the fact that when attempting to nav to something like the RecipeDetails route through something like a button click INSIDE of a region being driven by tabs/navview/etc., we would end up in a state where it would inject a FrameView as a child region of the PanelVisibilityNavigator and not do a full forward navigation at the root.

So we would end up with something like this:

Image

So currently the logic for checking if the PanelVisibilityNavigator can execute the nav request is this:

if (!await base.RegionCanNavigate(route, routeMap))
{
return false;
}
if (routeMap?.RenderView?.IsSubclassOf(typeof(FrameworkElement)) ?? false)
{
return true;
}
return await Dispatcher.ExecuteAsync(async cancellation =>
{
return FindByPath(routeMap?.Path ?? route.Base) is not null;
});

Last time, we discussed adding logic to determine if the route we are trying to nav to is defined as a named region that is a child of the current Region, otherwise it should let the nav request bubble up further to the root navigator.

We actually seem to already be doing that check here:

return FindByPath(routeMap?.Path ?? route.Base) is not null;

Problem is, we don't hit that check because this evals to true:

if (routeMap?.RenderView?.IsSubclassOf(typeof(FrameworkElement)) ?? false)
{
return true;
}

So basically if there is a valid RenderView for the route, it will always inject that view and nav to the requested region within that. Which is why we see the RecipeDetails page nested inside of the Favorites page underneath the Top TabBar.

Our thinking is that it should only inject the resolved RenderView if and only if the routeMap param that represents the route we are navigating to is a direct nested route of our current Region's root route. So, in our RecipeDetails example above, the RecipeDetails route is a sibling route of the current FavoriteRecipes route:

Image

so if the detected route is not nested within FavoriteRecipes, we should be navigating at a higher level than the PanelVisibilityNavigator attached to the TabBar.

Does this make sense? because there are three situations we need to cover that would result in doing a nested nav where the PanelVisibilityNavigator's RegionCanNavigate return true:

  1. Requested route matches a named child Region (covered)
  2. Requested route matches a known type, like say we had a UserControl for one of the regions (MySecondTabControl) and we navigated to "MySecondTab", it should inject MySecondTabControl as a child region and nav to it
  3. Requested route matches a known route that is a nested route of the current region's route path

And RegionCanNavigate should return false when:

  1. Requested route matches a known route that is NOT a nested route of the current region's route path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants