diff --git a/src/Uno.Extensions.Navigation.UI/Navigators/FrameNavigator.cs b/src/Uno.Extensions.Navigation.UI/Navigators/FrameNavigator.cs index c54b7380bf..6cf5ae66e4 100644 --- a/src/Uno.Extensions.Navigation.UI/Navigators/FrameNavigator.cs +++ b/src/Uno.Extensions.Navigation.UI/Navigators/FrameNavigator.cs @@ -151,6 +151,12 @@ viewType is null || RemoveLastFromBackStack(); } + var parentRegion = this.Region.Parent; + while (parentRegion is { } && + parentRegion.Name is null) + { + parentRegion = parentRegion.Parent; + } for (var i = 0; i < segments.Length - 1; i++) { @@ -160,6 +166,11 @@ viewType is null || continue; } + if (parentRegion?.Name == map.Path) + { + continue; + } + var newEntry = new PageStackEntry( map.RenderView, request.Route.NavigationData(), diff --git a/testing/TestHarness/TestHarness.Core/TestSections.cs b/testing/TestHarness/TestHarness.Core/TestSections.cs index 68f0790a8b..b0cb60fdb2 100644 --- a/testing/TestHarness/TestHarness.Core/TestSections.cs +++ b/testing/TestHarness/TestHarness.Core/TestSections.cs @@ -16,6 +16,7 @@ public enum TestSections Apps_Commerce, Apps_Commerce_ShellControl, Apps_ToDo, + Apps_Regions, Authentication_Custom, Authentication_Custom_Service, Authentication_Custom_TestBackend, diff --git a/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/ToDo/Given_Apps_ToDo.cs b/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/ToDo/Given_Apps_ToDo.cs index 9d08eb36d0..f8fdfd2e7e 100644 --- a/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/ToDo/Given_Apps_ToDo.cs +++ b/testing/TestHarness/TestHarness.UITest/Ext/Navigation/Apps/ToDo/Given_Apps_ToDo.cs @@ -40,4 +40,53 @@ public async Task When_ToDo_Responsive() } + [Test] + public async Task When_ToDo_Wide_Nav_ContentControl() + { + InitTestSection(TestSections.Apps_ToDo); + + App.WaitThenTap("ShowAppButton"); + + // Make sure the app has loaded + App.WaitElement("WelcomeNavigationBar"); + + // Login + await App.TapAndWait("LoginButton", "HomeNavigationBar"); + + // Select a task list + await App.TapAndWait("SelectTaskList2Button", "TaskListNavigationBar"); + + await App.TapAndWait("SelectActiveTask1Button", "TaskNavigationBar"); + + var screenBefore = TakeScreenshot("When_ToDo_Wide_Nav_ContentControl_Before"); + + await App.TapAndWait("DetailsBackButton", "TaskListNavigationBar"); + + var screenAfter = TakeScreenshot("When_ToDo_Wide_Nav_ContentControl_After"); + + ImageAssert.AreEqual(screenBefore, screenAfter, tolerance: PixelTolerance.Exclusive(Constants.DefaultPixelTolerance)); + } + + [Test] + public async Task When_ToDo_Narrow_Nav_ContentControl() + { + InitTestSection(TestSections.Apps_ToDo); + + App.WaitThenTap("ShowAppButton"); + + App.WaitThenTap("NarrowButton"); + + // Make sure the app has loaded + App.WaitElement("WelcomeNavigationBar"); + + // Login + await App.TapAndWait("LoginButton", "HomeNavigationBar"); + + // Select a task list + await App.TapAndWait("SelectTaskList2Button", "TaskListNavigationBar"); + + await App.TapAndWait("SelectActiveTask1Button", "TaskNavigationBar"); + + await App.TapAndWait("DetailsBackButton", "TaskListNavigationBar"); + } } diff --git a/testing/TestHarness/TestHarness/Assets/Images/back.svg b/testing/TestHarness/TestHarness/Assets/Images/back.svg new file mode 100644 index 0000000000..bcd7851b9c --- /dev/null +++ b/testing/TestHarness/TestHarness/Assets/Images/back.svg @@ -0,0 +1,3 @@ + + + diff --git a/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/FourthData.cs b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/FourthData.cs new file mode 100644 index 0000000000..371664a93e --- /dev/null +++ b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/FourthData.cs @@ -0,0 +1,6 @@ +namespace TestHarness.Ext.Navigation.Apps.Regions; + +public class FourthData +{ + public string Name { get; set; } +} diff --git a/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsFirstPage.xaml b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsFirstPage.xaml new file mode 100644 index 0000000000..5b04891fb9 --- /dev/null +++ b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsFirstPage.xaml @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsFirstPage.xaml.cs b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsFirstPage.xaml.cs new file mode 100644 index 0000000000..69040adb91 --- /dev/null +++ b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsFirstPage.xaml.cs @@ -0,0 +1,9 @@ +namespace TestHarness.Ext.Navigation.Apps.Regions; + +public sealed partial class RegionsFirstPage : Page +{ + public RegionsFirstPage() + { + this.InitializeComponent(); + } +} diff --git a/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsFourthPage.xaml b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsFourthPage.xaml new file mode 100644 index 0000000000..c8aedda26a --- /dev/null +++ b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsFourthPage.xaml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsFourthPage.xaml.cs b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsFourthPage.xaml.cs new file mode 100644 index 0000000000..0456015024 --- /dev/null +++ b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsFourthPage.xaml.cs @@ -0,0 +1,9 @@ +namespace TestHarness.Ext.Navigation.Apps.Regions; + +public sealed partial class RegionsFourthPage : Page +{ + public RegionsFourthPage() + { + this.InitializeComponent(); + } +} diff --git a/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsFourthViewModel.cs b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsFourthViewModel.cs new file mode 100644 index 0000000000..e7e67e3570 --- /dev/null +++ b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsFourthViewModel.cs @@ -0,0 +1,6 @@ +namespace TestHarness.Ext.Navigation.Apps.Regions; + +public class RegionsFourthViewModel (FourthData fourthData) +{ + public FourthData FourthData { get; set; } = fourthData; +} diff --git a/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsHomePage.xaml b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsHomePage.xaml new file mode 100644 index 0000000000..fb2c0b41fd --- /dev/null +++ b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsHomePage.xaml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsHomePage.xaml.cs b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsHomePage.xaml.cs new file mode 100644 index 0000000000..060386e887 --- /dev/null +++ b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsHomePage.xaml.cs @@ -0,0 +1,10 @@ +namespace TestHarness.Ext.Navigation.Apps.Regions +{ + public sealed partial class RegionsHomePage : Page + { + public RegionsHomePage() + { + this.InitializeComponent(); + } + } +} diff --git a/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsHostInit.cs b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsHostInit.cs new file mode 100644 index 0000000000..4c709926d1 --- /dev/null +++ b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsHostInit.cs @@ -0,0 +1,39 @@ +namespace TestHarness.Ext.Navigation.Apps.Regions; + +public partial class RegionsHostInit : BaseHostInitialization +{ + protected override void RegisterRoutes(IViewRegistry views, IRouteRegistry routes) + { + views.Register( + new ViewMap(ViewModel: typeof(RegionsShellModel)), + new ViewMap(), + new ViewMap(), + new ViewMap(), + new ViewMap(), + new DataViewMap() + ); + + routes.Register( + new RouteMap("", View: views.FindByViewModel(), + Nested: + [ + new ("RegionsHome", View: views.FindByView(), + Nested: + [ + new ("RegionsFirst", View: views.FindByView(), IsDefault: true, + Nested: + [ + new ("RegionsOne", IsDefault: true), + new ("RegionsTwo"), + new ("RegionsThree") + ] + ), + new ("RegionsSecond", View: views.FindByViewModel()), + new ("RegionsThird", View: views.FindByView()), + new ("RegionsFourth", View: views.FindByViewModel(), DependsOn: "RegionsSecond") + ]), + ] + ) + ); + } +} diff --git a/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsMainPage.xaml b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsMainPage.xaml new file mode 100644 index 0000000000..5a270d87ca --- /dev/null +++ b/testing/TestHarness/TestHarness/Ext/Navigation/Apps/Regions/RegionsMainPage.xaml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + +