diff --git a/src/Uno.Extensions.Hosting.UI/AppHostingEnvironment.cs b/src/Uno.Extensions.Hosting.UI/AppHostingEnvironment.cs index 083c8f6a1f..92e6336fb9 100644 --- a/src/Uno.Extensions.Hosting.UI/AppHostingEnvironment.cs +++ b/src/Uno.Extensions.Hosting.UI/AppHostingEnvironment.cs @@ -16,15 +16,14 @@ internal class AppHostingEnvironment : HostingEnvironment, IAppHostEnvironment, public Assembly? HostAssembly { get; init; } #if __WASM__ - public async Task UpdateAddressBar(Uri applicationUri) + public async Task UpdateAddressBar(Uri applicationUri, bool canGoBack) { CoreApplication.MainView?.DispatcherQueue.TryEnqueue(() => { var state = 1; if (PlatformHelper.IsWebAssembly) { - var currentView = SystemNavigationManager.GetForCurrentView(); - state = currentView?.AppViewBackButtonVisibility == AppViewBackButtonVisibility.Visible ? 1 : 0; + state = canGoBack ? 1 : 0; } var href = Imports.GetLocation(); diff --git a/src/Uno.Extensions.Hosting/IHasAddressBar.cs b/src/Uno.Extensions.Hosting/IHasAddressBar.cs index 36a0b768ec..e4296ad6e0 100644 --- a/src/Uno.Extensions.Hosting/IHasAddressBar.cs +++ b/src/Uno.Extensions.Hosting/IHasAddressBar.cs @@ -12,8 +12,11 @@ public interface IHasAddressBar /// /// The URI to update the address bar with. /// + /// + /// Whether it is possible to navigate back or not. + /// /// /// A task that completes when the address bar has been updated. /// - Task UpdateAddressBar(Uri applicationUri); + Task UpdateAddressBar(Uri applicationUri, bool canGoBack); } diff --git a/src/Uno.Extensions.Navigation.UI/BrowserAddressBarService.cs b/src/Uno.Extensions.Navigation.UI/BrowserAddressBarService.cs index b911e7d820..a82683569a 100644 --- a/src/Uno.Extensions.Navigation.UI/BrowserAddressBarService.cs +++ b/src/Uno.Extensions.Navigation.UI/BrowserAddressBarService.cs @@ -72,12 +72,14 @@ private async void RouteChanged(object? sender, RouteChangedEventArgs e) return; } + var canGoBack = rootRegion.Navigator() is { } navigator && await navigator.CanGoBack(); + var url = new UriBuilder { Query = route.Query(), Path = route.FullPath()?.Replace("+", "/") }; - await _addressbarHost!.UpdateAddressBar(url.Uri); + await _addressbarHost!.UpdateAddressBar(url.Uri, canGoBack); } catch (Exception ex) { diff --git a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/PageNavigation/PageNavigationOnePage.xaml b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/PageNavigation/PageNavigationOnePage.xaml index 8bc3db6f6b..a1175220ad 100644 --- a/testing/TestHarness/TestHarness.Shared/Ext/Navigation/PageNavigation/PageNavigationOnePage.xaml +++ b/testing/TestHarness/TestHarness.Shared/Ext/Navigation/PageNavigation/PageNavigationOnePage.xaml @@ -1,14 +1,14 @@  + Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" + mc:Ignorable="d"> @@ -16,60 +16,61 @@ - - + + -