[Bug] BlazorWebView with WindowsForms: keyboard and focus issues
See original GitHub issueDescription
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
withinBlazorWebView
- 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 intoBlazorWebView
. - The native WinForms menu is not dismissed when the focus moves into
BlazorWebView
(by clicking inside it). So I can type inside HTMLtextarea
while the menu is still shown:
.
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
- Install .NET 6.0.100-preview.7 SDK: https://dotnet.microsoft.com/download/dotnet/thank-you/sdk-6.0.100-preview.7-windows-x64-installer
- Clone the repo:
git clone https://github.com/noseratio/BlazorWebViewWinFormsApp .
- Run:
dotnet run
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
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
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 🙂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).