Skip to content

Fix random focus lost issues on CTRL+1/2 for a webview - #111676

Merged
Matt Bierner (mjbvz) merged 3 commits into
microsoft:masterfrom
rchiodo:rchiodo/focus_issue
Jan 8, 2021
Merged

Matt Bierner (mjbvz) merged 3 commits into
microsoft:masterfrom
rchiodo:rchiodo/focus_issue

Conversation

@rchiodo

Copy link
Copy Markdown
Contributor

This PR fixes #97992

What I believe is happening (after adding a bunch of logging) is that the blur here:

is also async when sent to a webview.

This can cause the blur to fire randomly, sometimes after the focus trigger has fired (but also sometimes before, when it works).

This should resolve the problem we've been having with microsoft/vscode-jupyter#1293 (or at least make it possible for us to handle focus correctly)

/cc Matt Bierner (@mjbvz)

// Clear the existing focus first if not already on the webview.
// This is required because the next part where we set the focus is async.
if (document.activeElement && document.activeElement instanceof HTMLElement) {
if (document.activeElement && document.activeElement instanceof HTMLElement && document.activeElement?.tagName !== 'WEBVIEW') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit pick: null propagation on the last check if not required as documet.activeElement is guaranteed to exist, due to first check

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Will fix

@mjbvz

Copy link
Copy Markdown
Contributor

Thanks for looking into this!

Can you make sure that this does not regress other cases, specifically:

I believe the existing code was written this way to handle those cases and I want to make sure we don't break them again

Make sure to test with both custom title bars enabled and with them disabled (use the window.titleBarStyle setting)

@rchiodo

Copy link
Copy Markdown
Contributor Author

Thanks Matt Bierner (@mjbvz) .

#75209 I had originally tested (well because my original implementation broke this bug) so that one I can say it still works. If I go to the settings icon while a webview has focus, the file theme picker will show up.

#101553 I think it still works? Does this gif show it working (meaning am I following the repro steps)?

undo

@mjbvz

Copy link
Copy Markdown
Contributor

Rich Chiodo (@rchiodo) The looks correct to me. Thanks for testing!

I've scheduled this for the December/January vscode iteration. This should give us lots of time to test this in insiders too

@rheh Ray Hammond (rheh) left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mjbvz
Matt Bierner (mjbvz) merged commit aa73c2d into microsoft:master Jan 8, 2021
@mjbvz Matt Bierner (mjbvz) added this to the January 2021 milestone Jan 8, 2021
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 22, 2021
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.

Switch group command not working as expected

3 participants