Skip to content
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

Merged
merged 16 commits into from
Feb 25, 2022
Merged

Implement WebView navigation events #4443

merged 16 commits into from
Feb 25, 2022

Conversation

jsuarezruiz
Copy link
Contributor

Description of Change

Implement WebView navigation events:

  • Navigating
  • Navigated

Fixes #3440

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

Does this PR touch anything that might affect accessibility?

  • No

@jsuarezruiz jsuarezruiz added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Feb 1, 2022
@jsuarezruiz jsuarezruiz marked this pull request as ready for review February 2, 2022 07:01
@@ -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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The event state appears to get stuck with whatever it was set to.

  • go to gallery for web view
  • navigate forward
  • click back
  • now click any links on the page

You'll get a navigating event with a CurrentWebNavigationEvent set to Back

Maybe this call can just be centralized into the handler?

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmarinho rmarinho requested a review from PureWeen February 18, 2022 12:42
Copy link
Member

@rmarinho rmarinho left a 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.
@Redth
Copy link
Member

Redth commented Feb 25, 2022

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

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
@Redth
Copy link
Member

Redth commented Feb 25, 2022

Approving but created #4938 to track some minor issues on iOS/MacCatalyst

/cc @mandel-macaque

@Redth Redth enabled auto-merge (squash) February 25, 2022 22:42
@Redth Redth dismissed stale reviews from rmarinho and PureWeen February 25, 2022 22:43

Fixes

@Redth Redth merged commit 28193a3 into main Feb 25, 2022
@Redth Redth deleted the webview-navigation-events branch February 25, 2022 23:11
@github-actions github-actions bot locked and limited conversation to collaborators Dec 22, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 2024
@samhouts samhouts added the fixed-in-6.0.200-preview.14.2 Look for this fix in 6.0.200-preview.14.2! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-controls-webview WebView fixed-in-6.0.200-preview.14.2 Look for this fix in 6.0.200-preview.14.2!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Navigating, Navigated events in WebViewHandler
6 participants