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

EvaluateJavaScriptAsync does not work if WebViewRenderer is used #9211

Closed
yaho86 opened this issue Aug 5, 2022 · 7 comments · Fixed by #12901
Closed

EvaluateJavaScriptAsync does not work if WebViewRenderer is used #9211

yaho86 opened this issue Aug 5, 2022 · 7 comments · Fixed by #12901
Assignees
Labels
area-controls-webview WebView fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! platform/android 🤖 t/bug Something isn't working
Milestone

Comments

@yaho86
Copy link

yaho86 commented Aug 5, 2022

Description

WebView.EvaluateJavaScriptAsync does nothing if WebViewRenderer is used. It works fine with default handler, though.

Probably caused by this condition

if (_evaluateJavaScriptRequested?.GetInvocationList().Length == 0)

Steps to Reproduce

  1. Enable compatibility mode and register WebViewRenderer
var builder = MauiApp.CreateBuilder();
builder
  .UseMauiApp<App>()
  .UseMauiCompatibility()
  .ConfigureMauiHandlers((handlers) => {
#if ANDROID
    handlers.AddCompatibilityRenderer(typeof(WebView), typeof(WebViewRenderer));
#endif
  });
  1. Add WebView like so <WebView Source="..." />
  2. Call WebView.EvaluateJavaScriptAsync("alert('Hello')") (or any other JS code)
  3. JS code is not executed

Version with bug

6.0.400

Last version that worked well

Unknown/Other

Affected platforms

Android, I was not able test on other platforms

Affected platform versions

Android 12

Did you find any workaround?

Use handler instead of renderer.

Relevant log output

No response

@yaho86 yaho86 added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Aug 5, 2022
@Eilon Eilon added the area-controls-webview WebView label Aug 5, 2022
@ghost ghost added the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label Aug 5, 2022
@jfversluis jfversluis removed the s/needs-verification Indicates that this issue needs initial verification before further triage will happen label Aug 12, 2022
@NiladriPadhy
Copy link

When using handlers instead of renderers, EvaluateJavaScriptAsync method not found since its implemented from IView interface. Need implementation for EvaluateJavaScriptAsync method.

@NiladriPadhy
Copy link

NiladriPadhy commented Sep 1, 2022

Any update on this?

@jsuarezruiz
Copy link
Contributor

issue-9211
Could you try with the latest version (net7 rc2)?. Tried but cannot reproduce the issue.

@jsuarezruiz jsuarezruiz added the s/needs-info Issue needs more info from the author label Oct 19, 2022
@jsuarezruiz jsuarezruiz self-assigned this Oct 19, 2022
@ghost
Copy link

ghost commented Oct 19, 2022

Hi @yaho86. We have added the "s/needs-info" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@Shishim4ru
Copy link

When using handlers instead of renderers, EvaluateJavaScriptAsync method not found since its implemented from IView interface. Need implementation for EvaluateJavaScriptAsync method.

Here you can find an implementation of the handler based on IWebView instead of IView https://github.com/Shishim4ru/MAUIWebViewExample

@ghost ghost added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Oct 23, 2022
@yaho86
Copy link
Author

yaho86 commented Dec 20, 2022

issue-9211 Could you try with the latest version (net7 rc2)?. Tried but cannot reproduce the issue.

It still doesn't work with the latest version of .NET 7.0.
The code from .NET MAUI Samples calls MauiWebView.Eval("alert('text')"); and it works. But on the next line it calls MauiWebView.EvaluateJavaScriptAsync() that doesn't work, see

var result = await MauiWebView.EvaluateJavaScriptAsync(

@jsuarezruiz jsuarezruiz removed the s/needs-attention Issue has more information and needs another look label Jan 25, 2023
@jsuarezruiz jsuarezruiz added this to the Backlog milestone Jan 25, 2023
@ghost
Copy link

ghost commented Jan 25, 2023

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@github-project-automation github-project-automation bot moved this from In Progress to Todo in MAUI SDK Ongoing Jan 27, 2023
@jsuarezruiz jsuarezruiz moved this to In Progress in MAUI SDK Ongoing Jan 27, 2023
@jsuarezruiz jsuarezruiz moved this from Todo to In Progress in MAUI SDK Ongoing Jan 27, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in MAUI SDK Ongoing Feb 2, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! label Feb 22, 2023
@samhouts samhouts modified the milestones: Backlog, 8.0-preview1 Feb 22, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Mar 24, 2023
@Eilon Eilon removed the legacy-area-controls Label, Button, CheckBox, Slider, Stepper, Switch, Picker, Entry, Editor label May 10, 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-8.0.0-preview.1.7762 Look for this fix in 8.0.0-preview.1.7762! platform/android 🤖 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants