diff --git a/src/Uno.Extensions.Navigation.UI/Navigators/SelectorNavigator.cs b/src/Uno.Extensions.Navigation.UI/Navigators/SelectorNavigator.cs index 8306c73353..a64cf56af7 100644 --- a/src/Uno.Extensions.Navigation.UI/Navigators/SelectorNavigator.cs +++ b/src/Uno.Extensions.Navigation.UI/Navigators/SelectorNavigator.cs @@ -106,7 +106,7 @@ private async void SelectionChanged(FrameworkElement sender, FrameworkElement? s } var item = (from mi in Items - where (mi.GetRegionOrElementName() == path) + where (mi.GetRegionOrElementName().WithoutQualifier() == path) select mi).FirstOrDefault(); return item; } diff --git a/src/Uno.Extensions.Navigation/RouteExtensions.cs b/src/Uno.Extensions.Navigation/RouteExtensions.cs index c357444537..c9602d3272 100644 --- a/src/Uno.Extensions.Navigation/RouteExtensions.cs +++ b/src/Uno.Extensions.Navigation/RouteExtensions.cs @@ -18,6 +18,7 @@ public static bool IsBackOrCloseNavigation(this Route route) => public static bool IsClearBackstack(this Route route) => route.Qualifier .StartsWith(Qualifiers.ClearBackStack); + public static string? ExtractBase(this string? path, out string nextQualifier, out string nextPath) { nextPath = path ?? string.Empty; @@ -71,6 +72,23 @@ public static string TrimStartOnce(this string text, string textToTrim) return text; } + public static string? WithoutQualifier(this string? path) + { + if(path is null || + string.IsNullOrWhiteSpace(path)) + { + return path; + } + + var qualifierMatch = nonAlphaRegex.Match(path); + if (qualifierMatch.Success && qualifierMatch.Index == 0) + { + return path.TrimStart(qualifierMatch.Value); + } + return path; + } + + public static string WithQualifier(this string path, string? qualifier) => (qualifier is null || string.IsNullOrWhiteSpace(qualifier)) ? path : $"{qualifier}{path}"; public static Route AsRoute(this RouteInfo map) diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Commerce/CommerceHomePage.xaml b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Commerce/CommerceHomePage.xaml index 7e4c9f5090..6473c45748 100644 --- a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Commerce/CommerceHomePage.xaml +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/Apps/Commerce/CommerceHomePage.xaml @@ -123,7 +123,7 @@ + uen:Region.Name="-/Products">