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

[Problem/Bug]: focus event does not trigger when switching to the window using alt+tab #4626

Open
HO-COOH opened this issue Jun 13, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@HO-COOH
Copy link

HO-COOH commented Jun 13, 2024

What happened?

One of our frontend site relies on focus event to function properly, but I observe that it does NOT trigger when switching from other window to the webview2 window using alt+tab keys.

Related issue #4420 (also having issues with focus event). This issue is much more serious tho, since it's about the event does not trigger instead of triggered twice. This issue does NOT happen in edge. Cef are also having bugs, but it does trigger the event.

Importance

Blocking. My app's basic functions are not working due to this issue.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

125.0.2535.92

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 to activate another window, then switch back to the webview2 window with alt+tab key. See the focus event it NOT triggered.

Edge:

2024-06-13.10-56-40.mp4

WebView2:

2024-06-13.10-58-12.mp4

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

@HO-COOH HO-COOH added the bug Something isn't working label Jun 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants