Skip to content

[Problem/Bug]: [ Broken] Events NewWindowRequested and WindowCloseRequested are not working together #5261

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

Open
DotNet-Fan opened this issue May 31, 2025 · 2 comments
Assignees
Labels
bug Something isn't working regression Something used to work but doesn't anymore

Comments

@DotNet-Fan
Copy link

DotNet-Fan commented May 31, 2025

What happened?

Webview2 WindowCloseRequested is not firing at all. This is broken.
We subscribe to NewWindowRequested and WindowCloseRequested events.
In the NewWindowRequested handler, we set the new window parent to the same webview2 instance so that it would show in the same webview2 instance.
This is for the Google social login which would be opened by default as a new window popup.

private void CoreWebView2_NewWindowRequested(CoreWebView2 sender, CoreWebView2NewWindowRequestedEventArgs e)
{

e.Handled = true;
if (sender != null)
e.NewWindow = sender;
}

When the google social login popup is closed after login , the WindowCloseRequested event does not fire at all.
This was working earlier.

Importance

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

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

136.0.3240.92

SDK Version

Microsoft.UI.Xaml.Controls - v 2.8.7

Framework

WinUI2/UWP

Operating System

Windows 11

OS Version

Microsoft Windows [Version 10.0.22631.4317]

Repro steps

In UWP App , add a webview2 control.
Then make sure that Corewebview2 is initialized using EnsureCoreWebView2Async call.
Once initialized in the CoreWebView2Initialized handler subscribe to CoreWebView2.NewWindowRequested and CoreWebView2.WindowCloseRequested event.
In the CoreWebView2.NewWindowRequested handler add the below code

private void CoreWebView2_NewWindowRequested(CoreWebView2 sender, CoreWebView2NewWindowRequestedEventArgs e)
{

e.Handled = true;
if (sender != null)
e.NewWindow = sender;
}

  • Navigate to www.x.com or www.pinterest.com and click on Google login.

  • This opens the google new window in the same instance of webview2.

  • After successful login and close of the popup , the WindowCloseRequested event is not fired .

This was working earlier and the code is broken now.

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

Worked in 130.0.2849.68

Last working version (if regression)

130.0.2849.68

@DotNet-Fan DotNet-Fan added the bug Something isn't working label May 31, 2025
@sivMSFT sivMSFT added the regression Something used to work but doesn't anymore label Jun 3, 2025
@sivMSFT
Copy link

sivMSFT commented Jun 3, 2025

Hi @DotNet-Fan,

I am confused by this point, mentioned by you in the description:

Regression
No, this never worked

Last working version (if regression)
130.0.2849.68 

Could you please check and share if it was working in 136?

@DotNet-Fan
Copy link
Author

DotNet-Fan commented Jun 4, 2025

@sivMSFT This is not working in 136. The version that we have integrated is 130 (fixed version) and it worked. Updated description.

@sivMSFT sivMSFT assigned dhveerap and gourabkmsft and unassigned dhveerap Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression Something used to work but doesn't anymore
Projects
None yet
Development

No branches or pull requests

5 participants