MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
452 stars 55 forks source link

[UWP] Webview2 New popup window is not focused(Not Active) on Main window(opened the behind the main window) #2468

Open Suresh-BabuLV opened 2 years ago

Suresh-BabuLV commented 2 years ago

Hi Team,

We have developed one UWP app that app need to learn courses when we click on learn course window that window open in new popup window We are not able to see that new course window in UWP but try to see that new window to click Task manager to open that window in windows OS, It is not possible to see that New popup (Course) in Kiosk

I have tried below code to open new course window on same(Main) window but blank window is opened

private void CoreWebView2_NewWindowRequested(Microsoft.Web.WebView2.Core.CoreWebView2 sender, Microsoft.Web.WebView2.Core.CoreWebView2NewWindowRequestedEventArgs args)
{
args.Handled = true;
args.NewWindow = (Microsoft.Web.WebView2.Core.CoreWebView2)sender;
args.GetDeferral().Complete();
}

Requirement: Need to Focus(Active) that popup window on top of that Main window

second time tried methods as per the senior experts input tried but not working as expected. image

I have tried alternate ways but doesn't work for me, Please provide your valuable suggestions to resolve this issue

Thanks in Advance

Regards, Suresh.

AB#39767326

Suresh-BabuLV commented 2 years ago

Hi @johna-ms, @champnic

Please provide your inputs to resolve this issue. I am eagerly waiting to your response why because due to hanged only this issue in my project

Thanks in Advance

Regards, Suresh.

champnic commented 2 years ago

Hey @Suresh-BabuLV - thanks for the question. Just to clarify, when you say "It is not possible to see that New popup (Course) in Kiosk" is that the same issue as the title of this issue, in that it's just hidden behind the current app?

For your second code example, you can create your own new UWP window, have a WebView2 in that new window, and then pass that WebView2's CoreWebView2 to the NewWindowRequested event args. The general pattern of NewWindowRequested is that it allows you to show and manage your own window however you like, with the WebView2 inside it. I'm also curious why "args.handled" was set to false, given it looks like you are handling the event and manually navigating a new window the to target uri?

@johna-ms Are there known issues with a new window being shown in the background?

@yildirimcagri Do you know if it's valid to pass the current WebView2 as the handler of a NewWindowRequested (from the first code block)?

johna-ms commented 2 years ago

I didn't know there was an issue here, but I looked into and looks like new window does show up in the background.

@Suresh-BabuLV could you verify if you are using UWP or WinUI3?

Suresh-BabuLV commented 2 years ago

Hey @Suresh-BabuLV - thanks for the question. Just to clarify, when you say "It is not possible to see that New popup (Course) in Kiosk" is that the same issue as the title of this issue, in that it's just hidden behind the current app?

@champnic , Yes opened behind the current app, We are not able to see that new course window only listening the course audio on Kiosk mode

For your second code example, you can create your own new UWP window, have a WebView2 in that new window, and then pass that WebView2's CoreWebView2 to the NewWindowRequested event args. The general pattern of NewWindowRequested is that it allows you to show and manage your own window however you like, with the WebView2 inside it. I'm also curious why "args.handled" was set to false, given it looks like you are handling the event and manually navigating a new window the to target uri?

@champnic ,Yes you are absolutely right, but we have tried both ways 1.args.Handled=true. not able to open that new course popup window on same main window. 2.args.Handled=false also tried this way we will do to open that new course window but it couldn't

**Requirement to just show that new course window on top of that main window.And it would be good to have default popup window.

Also, We have tried args.Handled property true/false and Removed the New window requested event but result would be the same that new course popup window opened the behind the main window.**

Please help me to get-out of this issue.

@johna-ms, Yes You are Right. Now opened in the background if opened the background in kiosk mode user is not able to see that new course window, Need to activate and get into focus that new course window on top of that main window will resolve the issue.

We are using UWP only.

Thanks in Advance

Regards, Suresh.

champnic commented 2 years ago

Thanks for the added info @Suresh-BabuLV - I've added this bug to our backlog.

yildirimcagri-msft commented 2 years ago

Being able to pass self to the NewWindowRequested event as a NewWindow is fine and it will navigate the existing WebView2. There could be a hosting related issue with creating windows in UWP, @champnic added this to our backlog and we'll investigate. Thanks!

Suresh-BabuLV commented 2 years ago

@champnic ,Thanks.

@yildirimcagri, Great Thanks,

It would be great to me to know when we have fix this issue to integrate in my project and deliver the project.

Thanks in Advance

Regards, Suresh.

Suresh-BabuLV commented 2 years ago

@yildirimcagri , Great thanks to looking into this issue.

Please Provide the version of webview2 have this issue fixes.

Regards, Suresh.

champnic commented 2 years ago

Hey @Suresh-BabuLV - Once we have build and shipped the fix for this issue, we'll update with the version info. Thanks!

Suresh-BabuLV commented 2 years ago

@champnic, Great Thanks for your quick response and support on this request.

Can you please share the timeline or possible by when we can expect this to be available when you get a moment – That will great help us”

Regards, Suresh.

champnic commented 2 years ago

We have this as a P1 on our backlog, so I would expect it be resolved over the next few months. Thanks!

Suresh-BabuLV commented 2 years ago

@champnic, Great thanks for your response.

I would request you to get the timeline for this issue almost 1 month over. We would hanged due to this issue to launch the app. Kindly resolve this issue. It would be great appreciation for resolving this issue.

Regards, Suresh.

Suresh-BabuLV commented 2 years ago

Hi @champnic, @yildirimcagri,

Greetings!!!.

“It is been quite for more than 2 months now – can some one please update if we can expect this fix anytime”

Thanks in Advance

Regards, Suresh.

champnic commented 2 years ago

Hey @Suresh-BabuLV - This item hasn't been assigned to an engineer yet, so we have not started investigation. We don't have an accurate timeline on this issue.

koenvd commented 1 year ago

Hey @champnic

We're also facing this same - a bit annoying for the user - issue on WinUI3.0 desktop apps.

I did some more tests:

So this might look like some specific WinUI3.0 inconsistency between having or not having an event handler subscribed the very first time the event is raised.

Also wondering if we should not move this to the WinUI3.0 repo to get a higher chance of this being looked at and fixed?

koenvd commented 1 year ago

Still wondering if this has to be moved to the WinUI3.0 repo at this point @champnic to get this fixed?

champnic commented 1 year ago

Hey @koenvd - It can't hurt to also have this on the WinUI3 repo, but my gut feeling is that if just handling the event with an empty handler is causing this then it's probably on the WebView2 side.

mohitvij commented 8 months ago

Hi @champnic any update on this. We are having same issue as well. This bug has stayed open for a while and resolution will be much appreciated.

mohitvij commented 7 months ago

@johna-ms @champnic @yildirimcagri-msft Gentlemen, Please move this higher up in your list of bug fixes! For those trusting WinUi, it becomes essential this feature works to create extensible applications. Eagerly waiting for a status change

pubtom commented 3 weeks ago

@champnic Any update on this issue?

Thanks

champnic commented 2 weeks ago

No updates on this issue. It's not currently being worked on.

tipa commented 2 days ago

I'm encountering the same problem in a UWP app. I am using WebView2 for OAuth authentication with Dropbox. When clicking the "Continue with Apple" button in the Dropbox authentication page, it opens a new window, which is placed behind the app's main window and the user is left behind confused because seemingly nothing happened.

I also tried to show a new AppWindow with a WebView2 instance and connecting the two via NewWindow, but the main window keeps stealing focus of the app window, making it impossible to finish the authentication process