Skip to content

Commit

Permalink
Merge pull request #755 from unoplatform/dev/nr/tabrootnav
Browse files Browse the repository at this point in the history
fix: Makes sure that any qualifiers are trimmed when locating selectable region
  • Loading branch information
nickrandolph authored Sep 26, 2022
2 parents a585be8 + 76d1712 commit b1c5dda
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
18 changes: 18 additions & 0 deletions src/Uno.Extensions.Navigation/RouteExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
</utu:TabBarItem>
<utu:TabBarItem AutomationProperties.AutomationId="ProductsTabBarItem"
IsSelectable="True"
uen:Region.Name="Products">
uen:Region.Name="-/Products">
<utu:TabBarItem.Icon>
<PathIcon Data="{StaticResource Icon_storefront}" />
</utu:TabBarItem.Icon>
Expand Down

0 comments on commit b1c5dda

Please sign in to comment.