[Fix] Webview is not focused after cancelling quick open widget #8137
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Signed-off-by: Shahar Harari [email protected]
What it does
Fixes the following issue:
When quick open widget is triggered while some webview is focused, cancelling the quick open widget doesn't bring focus back to webview. As a result, when triggering quick open widget again by pressing
F1
a new browser tab is opened instead.Root cause of this issue:
When closing quick open widget by pressing escape or changing focus, focus is set to the
previousFocusElement
:theia/packages/monaco/src/browser/monaco-quick-open-service.ts
Lines 235 to 238 in 7a88d28
previuosFocusElement
is webview main frame(The one withwebview
class) in case webview was focused before triggering the quick open widget, so it's being focused, but sincekeydown
handler is registered on the inner frame (The one withactive-frame
id)keydown
events will stop work from this point until the inner frame is focused manually:theia/packages/plugin-ext/src/main/browser/webview/pre/main.js
Line 535 in 7a88d28
My solution is register to
focus
events on main webview node and send focus message to inner frame in this case.How to test
F1
and chooseGitLens: Welcome
from the command palette.F1
and then pressEsc
key or mouse left click outside the quick open widget.F1
again - the quick open widget should be opened again. Without the fix a new browser tab will be opened instead.Before:
After:
Review checklist
Reminder for reviewers