Skip to content

Commit

Permalink
fix(WebView): Update Android navigation properties on JS-based histor…
Browse files Browse the repository at this point in the history
…y changes

When JS-based navigation changes the history properties, we can't recognize this in WebView using conventional navigation events. However, it should still influence history properties.
  • Loading branch information
MartinZikmund committed Jul 18, 2023
1 parent 3281b5c commit a0c229f
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
using System.Globalization;
using Android.Graphics;
using Android.Runtime;
using Android.Views;
using Android.Webkit;
using Microsoft.Web.WebView2.Core;
using Windows.UI.Xaml.Controls;
using Windows.Web;

namespace Uno.UI.Xaml.Controls;
Expand All @@ -26,6 +24,16 @@ internal InternalClient(CoreWebView2 coreWebView, NativeWebViewWrapper webViewWr
_nativeWebViewWrapper = webViewWrapper;
}

public override void DoUpdateVisitedHistory(Android.Webkit.WebView view, string url, bool isReload)
{
base.DoUpdateVisitedHistory(view, url, isReload);

_coreWebView.DocumentTitle = view.Title;

_nativeWebViewWrapper.RefreshHistoryProperties();
_coreWebView.RaiseHistoryChanged();
}

#pragma warning disable CS0672 // Member overrides obsolete member
public override bool ShouldOverrideUrlLoading(Android.Webkit.WebView view, string url)
#pragma warning restore CS0672 // Member overrides obsolete member
Expand Down Expand Up @@ -62,9 +70,6 @@ public override void OnPageFinished(Android.Webkit.WebView view, string url)
{
_coreWebView.DocumentTitle = view.Title;

_nativeWebViewWrapper.RefreshHistoryProperties();
_coreWebView.RaiseHistoryChanged();

var uri = !_nativeWebViewWrapper._wasLoadedFromString && !string.IsNullOrEmpty(url) ? new Uri(url) : null;

_coreWebView.RaiseNavigationCompleted(uri, true, 200, CoreWebView2WebErrorStatus.Unknown);
Expand Down

0 comments on commit a0c229f

Please sign in to comment.