MicrosoftEdge / MicrosoftEdge/WebView2Feedback

focus event triggered twice after window activated

Open
#4,420 1 comment 0 reactions 1 assignee View on GitHub

@tochukwuIbeEkeocha is already working on this.

Since Mar 13, 2024.

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

Description

What happened?

One of our frontend site relies on focus event to function properly, and I noticed this event handler triggered twice the first time the window was clicked. And this does NOT happens in Edge / Cef / Chrome.

Importance

Moderate. My app's user experience is affected, but still usable.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

No response

SDK Version

No response

Framework

Win32

Operating System

Windows 10, Windows 11

OS Version

No response

Repro steps
  1. Create a index.html with this
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Test</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="">
        <style>
            div {
                background-color: white;
            }
        </style>
    </head>
    <body>
        <div id="container">

        </div>
        
        <script>
            let i = 0;
            addEventListener("focus", ()=>{
                let container = document.getElementById('container');
                let newDiv = document.createElement('div');
                newDiv.innerHTML = `focus #${i}`;
                ++i;
                container.appendChild(newDiv);
            })
        </script>
    </body>
</html>
  1. Use whatever live server to host this page, use the official win32 starting sample and change the startup url from bing to this.
  2. Build it, run the exe without debugger.
  3. Click on the window, notice the event handler was called twice.

In this video, the first exe is the win32 official getting start sample, the second exe is cefsimple

https://github.com/MicrosoftEdge/WebView2Feedback/assets/42881734/9d36558e-ac00-498b-9e51-45299fc73b77

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

No, this never worked

Last working version (if regression)

No response

AB#49543165

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.