Synchronous prompt on CustomScriptDialogOpening WebView2
See original GitHub issueDescription
I’m developing a MAUI application in C# that implements a WebView2 and I need to change the style of the alert, prompt, and confirm dialogs. In WinUI applications everything is very modern, avoiding synchrony, but apparently only when it suits Microsoft, let me explain: If I do:
webView.CoreWebView2.Settings.AreDefaultScriptDialogsEnabled = false;
webView.CoreWebView2.ScriptDialogOpening += CustomScriptDialogOpening;
I can intercept the default JavaScript dialogs, but even if the CustomScriptDialogOpening function is async, the WebView doesn’t await it.
So,
How the heck can I make a prompt if I can’t await it, And there’s no way to launch the user prompt window synchronously, and if I launch it asynchronously, WebView2 doesn’t await it?
I don’t know if this has a solution… Thank you!
Steps to Reproduce
Create MAUI project with windows support. Add webview. Set AreDefaultScriptDialogsEnabled = false add Event on ScriptDialogOpening
Link to public reproduction project repository
https://github.com/MicrosoftEdge/WebView2Feedback
Version with bug
6.0.312
Last version that worked well
6.0.312
Affected platforms
Windows
Affected platform versions
Windows
Did you find any workaround?
No response
Relevant log output
No response
Issue Analytics
- State:
- Created 5 months ago
- Comments:7 (3 by maintainers)
True…
My mistake due to ignorance.
I didn’t know this. It was so easy, and I didn’t know how to find the answer. Thank you Eilon. And thank you for the work you do with HybridWebview.
We had something similar in Xamarin, and your project encouraged us to switch to MAUI. 😃
Thanks again.
You’re quite welcome. When I started using WebView2 it was the first time I saw this pattern as well, and was quite surprised by it!