-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement WebView navigation events #4443
Conversation
@@ -56,16 +68,23 @@ public static void MapWebViewSettings(WebViewHandler handler, IWebView webView) | |||
|
|||
public static void MapGoBack(WebViewHandler handler, IWebView webView, object? arg) | |||
{ | |||
if (handler.NativeView.CanGoBack()) | |||
handler.CurrentWebNavigationEvent = WebNavigationEvent.Back; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found the issue, this is the pending piece of code: https://github.com/xamarin/Xamarin.Forms/blob/caab66bcf9614aca0c0805d560a34e176d196e17/Xamarin.Forms.Platform.Android/Renderers/FormsWebViewClient.cs#L66
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems something is making it crash on Android.. but not much info on the output.
Steps to reproduce:
- Go to WebView page
- Click dotnet
- Click GoBack
- Click GoForward
- Click GitHub logo
Crash
On windows when i click back it navigates again to the current page:
Navigating - Url: https://github.com/dotnet/maui, Event: Back
Navigated - Url: https://github.com/dotnet/maui, Event: Back, Result: Success
Navigating - Url: https://github.com/dotnet, Event: NewPage
Navigated - Url: https://github.com/dotnet, Event: NewPage, Result: Success
Now using the CoreWebView2 events on Windows which lets us use the history changed event so that updating cangoback/forward status works when navigating in the view.
these are fixed with my changes |
The apple docs state that if the newer decidePolicy method is implemented, the older one will not be called. The concrete delegate implementation implements the newer one, so we can't use it without using the newer method which is only available on iOS13+. To make it easier to still work on older versions, we can just implement the interface and export what we need instead. https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview?language=objc#discussion
Approving but created #4938 to track some minor issues on iOS/MacCatalyst /cc @mandel-macaque |
Description of Change
Implement WebView navigation events:
Fixes #3440
PR Checklist
Does this PR touch anything that might affect accessibility?