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

[Bug] BlazorWebView with WindowsForms: keyboard and focus issues #2341

Closed
noseratio opened this issue Sep 1, 2021 · 10 comments
Closed

[Bug] BlazorWebView with WindowsForms: keyboard and focus issues #2341

noseratio opened this issue Sep 1, 2021 · 10 comments
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView external feature-blazor-windesktop Issues in Blazor in WPF or WinForms partner/webview2 Issues depending on Edge WebView2 s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working

Comments

@noseratio
Copy link

noseratio commented Sep 1, 2021

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 (Alt-F4, Alt-Space) 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 Tab the focus (and the cursor) disappears . Then It takes an extra Tab 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, Alt-F4 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

@Eilon
Copy link
Member

Eilon commented Sep 15, 2021

On RC2 I'm seeing some similar, but slightly different behavior. I am working on updating to WebView2 1.0.961.33 as well, so that probably introduces some differences.

In WinForms I now see:

  • Alt+F4 works regardless of where focus is
  • Alt+Space does not work when WebView2 is in focus (works when it isn't in focus)
  • Accessing menu accelerators (such as Alt+F for the File menu) does not work when WebView2 is in focus (works when it isn't in focus)
  • Accessing menu item accelerators (such as Ctrl+O for Open) does not work when WebView2 is in focus (works when it isn't in focus)
  • In input type=text and in textarea, all keyboard caret motion and shortcuts work (arrows, pgup/pgdn/home/end, ctrl+a, clipboard commands, selection, etc.)
  • I can tab around everywhere all the time, including native & web textboxes and buttons

@Eilon
Copy link
Member

Eilon commented 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).

@noseratio
Copy link
Author

noseratio commented Sep 15, 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 🙂

@Eilon Eilon added the partner/webview2 Issues depending on Edge WebView2 label Sep 17, 2021
@jsuarezruiz jsuarezruiz added the t/bug Something isn't working label Oct 22, 2021
@Eilon Eilon added the feature-blazor-windesktop Issues in Blazor in WPF or WinForms label Nov 23, 2021
@mkArtakMSFT mkArtakMSFT added this to the .NET 7 milestone Feb 23, 2022
@v-longmin v-longmin added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Mar 1, 2022
@v-longmin
Copy link

Verified reproes. Repro project:
BlazorWebViewWinFormsApp-main.zip

@mkArtakMSFT
Copy link
Member

@Eilon if there are any remaining issues to be filed from the list you've provided let's file this. Otherwise, if everything is already being tracked we should probably close this issue. Don't you think so?

@Eilon
Copy link
Member

Eilon commented Jun 29, 2022

Here's what works:

  1. Can tab forwards between native UI and web UI. When you get to the end, it cycles back around to the top as you expect. There are no extra "hidden" tab stops - only the truly focusable elements ever get focus
  2. All keypresses inside a textarea seem to work (arrows, ctrl+arrows, ctrl+c/v, etc.)
  3. Alt+F4 to close the app works when focused anywhere

And what doesn't work:

  1. You can tab backwards, but if you're in the WebView, shift+tab will cycle to the bottom of the WebView, instead of into the preceding native UI control
  2. Alt+F to open File menu doesn't work when focused in WebView
  3. Similarly, menu accelerators (such as Ctrl+S to Save) are ignored when focused in the WebView
  4. Alt+Space to open system menu does not work when focused in the WebView
  5. (Copied from original report) 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:

The situation now is that I'm not sure if any of these are BlazorWebView bugs, but rather all or almost all are WebView2 bugs.

@Redth Redth removed this from the .NET 7 + Servicing milestone Aug 29, 2022
@TanayParikh TanayParikh added this to the Backlog milestone Aug 30, 2022
@ghost
Copy link

ghost commented Aug 30, 2022

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.

@mkArtakMSFT mkArtakMSFT added the discussed Created by mkArtakMSFT to help with planning temporarily. It will be removed after planning is done. label Nov 3, 2022
@mkArtakMSFT mkArtakMSFT modified the milestones: Backlog, .NET 8 Planning Nov 3, 2022
@mkArtakMSFT
Copy link
Member

Moving to .NET 8 planning. We will need to work with the WebView2 team to shepherd these changes.

@mkArtakMSFT mkArtakMSFT removed the discussed Created by mkArtakMSFT to help with planning temporarily. It will be removed after planning is done. label Nov 16, 2022
@samhouts samhouts removed s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Apr 5, 2023
@Zhanglirong-Winnie Zhanglirong-Winnie added s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version labels Apr 11, 2023
@ghost
Copy link

ghost commented Apr 11, 2023

Hi @noseratio. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.

You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.

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.

@Zhanglirong-Winnie
Copy link

Verified on Visual Studio Enterprise 17.6.0 Preview 2.0. This issue does not repro with sample project.
BlazorWebViewWinFormsApp-main.zip

  1. Alt-F4 works and can successfully stop the project;
  2. Arrow keys work inside HTML textarea in Blazor WebView;
  3. Both Tab and Shift-Tad work;
  4. Alt-Space works and can successfully open the system menu;
  5. Alt-F works and successfully opens the file menu;

Screenshot 2023-04-11 154109
Screenshot 2023-04-11 154123

@ghost ghost closed this as completed Apr 19, 2023
@ghost ghost locked as resolved and limited conversation to collaborators May 19, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Blazor Hybrid / Desktop, BlazorWebView external feature-blazor-windesktop Issues in Blazor in WPF or WinForms partner/webview2 Issues depending on Edge WebView2 s/triaged Issue has been reviewed s/try-latest-version Please try to reproduce the potential issue on the latest public version t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

9 participants