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]: New windows open when it shouldn't #4224

Closed
Danielx64 opened this issue Dec 11, 2023 · 10 comments
Closed

[Problem/Bug]: New windows open when it shouldn't #4224

Danielx64 opened this issue Dec 11, 2023 · 10 comments
Assignees
Labels
bug Something isn't working

Comments

@Danielx64
Copy link

What happened?

I'm not sure what happens, we been running the same custom built app for months with no code changes and now our logic that tells webview2 to ignore any requests to open a new browser window isn't working.

		private void CoreWebView2_NewWindowRequested(object sender, CoreWebView2NewWindowRequestedEventArgs e)
		{
			if (e.Uri.Contains("powerapps"))
			{
				e.NewWindow = WebView.CoreWebView2;
			}
			else
			{
				e.Handled = false;
			}
		}

Importance

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

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

120.0.2210.61

SDK Version

1.0.2151.40

Framework

WPF

Operating System

Windows 10

OS Version

No response

Repro steps

Use the following code (change URL etc as need be:

		private void CoreWebView2_NewWindowRequested(object sender, CoreWebView2NewWindowRequestedEventArgs e)
		{
			if (e.Uri.Contains("powerapps"))
			{
				e.NewWindow = WebView.CoreWebView2;
			}
			else
			{
				e.Handled = false;
			}
		}

And attach it to the WebView.CoreWebView2.NewWindowRequested event.

Repros in Edge Browser

Not Applicable

Regression

Regression in newer Runtime

Last working version (if regression)

Runtime 119.0.2151.97 (I think)

@Danielx64 Danielx64 added the bug Something isn't working label Dec 11, 2023
@litski18
Copy link

We are also facing the same issue. Please help.

@victorhuangwq
Copy link
Collaborator

We are currently looking into this issue

@Danielx64
Copy link
Author

Thank you :)

@Danielx64
Copy link
Author

@victorhuangwq is this considered a regression or is it still being looked into?

@Danielx64
Copy link
Author

@victorhuangwq just reporting that this is still happening on runtime 120.0.2210.77

@iGThomas
Copy link

Same issue here suddenly due to some update on Edge since 120.0.2210.61 the new window events aren't cancelled with e.NewWindow = webView21.CoreWebView2;. I've been running the code for 2 years already without issues until now.

@Danielx64
Copy link
Author

For now, I have been forced to turn my 2mb install size into close to 500mb install while I include the runtime to fix the issue.

@monica-ch
Copy link
Contributor

Closing the issue as duplicate of #4250

@yildirimcagri-msft
Copy link
Member

From the issue description, this may potentially be a distinct issue from #4250 as IIUC you are expecting WebView to ignore the NewWindowRequest with this code snippet so I'm reopening this issue to clarify.

In the snippet, if the URL is a specific URL(contains powerapps) then it seems you are setting the NewWindow to be the origin WebView, which would run into the issue manifested in #4250 (and would be fixed) and the new window request would simply be a navigation of the origin WebView.

However, in other cases, you are setting Handled to false and it sounds like you are expecting that this should cause WebView to ignore the request to new window. When Handled set to false, this would mean that the app is not handling the event and the default behavior of opening a popup window should apply. If you'd like to block the webview from opening new windows you would actually need to set the Handled property to true. If it was not opening the window before Edge 119 with this same code, it would mean the old behavior was wrong.

Does this match your expectation?

@Danielx64
Copy link
Author

@yildirimcagri-msft I'm back on deck after having 3 weeks off.

So in a nutshell if the url contains powerapps I do not want a new window to open while for all other requests, open a new window.

I just checked with runtime 120.0.2210.133 and it's working the way it should now.

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

8 participants