MicrosoftEdge / MicrosoftEdge/WebView2Feedback

[WinForms] Focus and KeyDown bugs.

Open
#721 11 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug priority-low tracked
Dominant language
PowerShell
Stars
526
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Description

  • WebView2 Can't be focused with mouse while in nonInit State. With tab focus change all is ok.
  • After Init, WebView2 can be focused with mouse, but KeyDown will behave wrong (see below). With tab focus change all is ok.

WVHK

Version
SDK: 1.0.664.37
Runtime: Evergreen WebView2 Runtime
Framework: .Net core 3.1
OS: Win10,2004

Repro Steps

Code
public partial class Form1 : Form
{
    private string _LastText;
    public Form1()
    {
        InitializeComponent();
        webView21.KeyDown += WebView21_KeyDown;
    }

    private void WebView21_KeyDown(object sender, KeyEventArgs e)
    {
        string info = $"Key: {e.KeyCode}; KeyData: {e.KeyData}; Control: {e.Control}.\n";
        if (_LastText != info)
        {
            _LastText = info;
            richTextBox1.Text += info;
        }

        if (e.KeyData == (Keys.Control | Keys.G))
            e.Handled = true;
    }

    private async void btnInit_Click(object sender, EventArgs e)
    {
        await webView21.EnsureCoreWebView2Async().ConfigureAwait(true);
    }
}

WebView2Test.zip

Additional context
Related issue (was closed): https://github.com/MicrosoftEdge/WebView2Feedback/issues/288.
Issues probably related to focus bugs: https://github.com/MicrosoftEdge/WebView2Feedback/issues/397, https://github.com/MicrosoftEdge/WebView2Feedback/issues/686, https://github.com/MicrosoftEdge/WebView2Feedback/issues/718.

AB#31029009

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the attached WebView2Test.zip reproduction with the shown C# handlers and SDK/runtime versions. Check focus by mouse before and after EnsureCoreWebView2Async, then inspect the KeyDown output and Ctrl+G handling; done means both mouse focus and keyboard events behave consistently with tab focus.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.