Skip to content

Fix webview focus steal that occurs when the application is re-focused#98847

Merged
mjbvz merged 7 commits intomicrosoft:masterfrom
Linskeyd:fix-webview-focus-steal
Jul 13, 2020
Merged

Fix webview focus steal that occurs when the application is re-focused#98847
mjbvz merged 7 commits intomicrosoft:masterfrom
Linskeyd:fix-webview-focus-steal

Conversation

@Linskeyd
Copy link
Contributor

This PR fixes #61489

Prior to this change, webviews could steal focus when the application window itself has been re-focused (as long as a webview was the last active editor element). As called out in #61489, even if something like the output panel or terminal was last focused, performing an alt+tab to switch between application windows and then back again would cause the webview to steal focus from other parts of the application.

After this change, we webviews only take focus back on application window refocus when they were actually last focused in the application window (when compared to the output panel, file explorer, or other editor layout parts). Tested locally on Mac.

IWorkbenchLayoutService seemed like the right thing to pull in to assert whether or not the last focused part of the application was indeed an editor (so that focus does not travel across layout parts). However, if there is better service or dependency to pull in here to check this condition, then I'd be happy to move to it :).

Thanks!

@Linskeyd
Copy link
Contributor Author

Linskeyd commented Jun 3, 2020

@mjbvz -> it looks like the VS Code CI failure was only on windows, and seems unrelated to my change. Known issue?

@mjbvz mjbvz added this to the June 2020 milestone Jun 4, 2020
@mjbvz
Copy link
Collaborator

mjbvz commented Jun 4, 2020

Thanks @Linskeyd! It's a bit too late in our development cycle to include this in the May release, but I'll take a look for the June release

@kieferrm kieferrm modified the milestones: June 2020, July 2020 Jul 6, 2020
@lwb4
Copy link

lwb4 commented Jul 13, 2020

It's now mid-July, any idea if/when this will be included in a release?

@mjbvz mjbvz merged commit 9bea23b into microsoft:master Jul 13, 2020
@mjbvz
Copy link
Collaborator

mjbvz commented Jul 13, 2020

Thanks! Merging this. It will be in the next VS Code insiders build

Charles-Gagnon pushed a commit to Charles-Gagnon/vscode that referenced this pull request Jul 14, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Aug 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Webviews take focus when vs code is refocused

4 participants