question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] BlazorWebView with WindowsForms: keyboard and focus issues

See original GitHub issue

Description

Below are some usability issues I’ve discovered while paying with BlazorWebView using WinForms and .NET v6.0.100-preview.7 SDK. A BlazorWebView/WinForms repo to reproduce. I haven’t tried it with WPF or WinUI yet, but I’d expect the same behavior:

  • Windows system accelerators (<kbd>Alt-F4</kbd>, <kbd>Alt-Space</kbd>) don’t work when the focus is inside BlazorWebView.
  • The arrow keys don’t work inside HTML textarea within BlazorWebView
  • Upon tabbing out of the native WinForms TextBox with <kbd>Tab</kbd> the focus (and the cursor) disappears . Then It takes an extra <kbd>Tab</kbd> to move the focus into BlazorWebView.
  • The native WinForms menu is not dismissed when the focus moves into BlazorWebView (by clicking inside it). So I can type inside HTML textarea while the menu is still shown:
    BlazorWebView.

I realize that some of these (like lingering menus) might be specific to WebView2 + WinForms. However, in a similar non-Blazor WebView2 app (just static HTML with WebView2 runtime v92.0.902.84 and SDK 1.0.955-prerelease) at least the arrow keys, <kbd>Alt-F4</kbd> and tabbing work as expected.

Perhaps, BlazorWebView just needs to update the WebView2 SDK dependencies? I’ve tried that but I’m getting this error:

System.MissingMethodException: Method not found: 'Void Microsoft.Web.WebView2.WinForms.WebView2.add_AcceleratorKeyPressed(System.EventHandler`1<Microsoft.Web.WebView2.Core.CoreWebView2AcceleratorKeyPressedEventArgs>)'.

Steps to Reproduce

Expected Behavior

Functional keyboard accelerators and focus handling.

Actual Behavior

See the above.

Basic Information

  • Version with issue: x64 Windows 10 v19043.1165 and .NET v6.0.100-preview.7

Reproduction Link

https://github.com/noseratio/BlazorWebViewWinFormsApp

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
noseratiocommented, Sep 30, 2021

Thanks for an update, looking fwd to those WebView2 fixes. I’m lobbying to open-source the .NET components of WV2, so the community could help with the issues like that 🙂

Also, well done on BlazorWebView. It may indeed become a great alternative to Electron for folks who want to develop desktop apps with C#. I was a bit skeptical when I approached it first, but as I’m learning more, I believe it has a lot of potential. Hopefully, it’ll be ready for its full prime with .NET 7 🙂

2reactions
Eiloncommented, Sep 15, 2021

Plus, as it seems you’ve certainly noticed, these issues at least mostly (if not entirely?) seem to be due to WebView2, per the issues and comments you’ve logged:

We have regular communication with the WebView2 folks so I’m hopeful we can get these issues resolve because I agree it does make the WebView2 hybrid app experience unusable for keyboard scenarios (and boy oh boy am I myself a hardcore keyboard user, let alone many who can only use keyboard or other similar input/accessibility devices).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can I make a Blazor application that doesn't open in ...
When I make a Blazor app, it always opens in a new browser tab with a list of pages on the left side...
Read more >
Known Issues in WebView control - Windows
This guide highlights known limitations with the current release of the WebView control for Windows Forms and WPF applications.
Read more >
WPF in 2021: alive, dead or on life support?
My own struggle with WPF + WebView2 keyboard and focus issues: ... releasing WebView2-based BlazorWebView , supported on WinForms, WPF and .
Read more >
David Ortinau, Author at .NET Blog
The main focus of the release is on bug fixes and quality improvements. ... The BlazorWebView controls for WPF and Windows Forms are...
Read more >
Build a Windows Forms Blazor app
This tutorial shows you how to build and run a Windows Forms Blazor app. You learn how to: Create a Windows Forms Blazor...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Hashnode Post

No results found