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

Implement WebviewPanel.reveal() #4787

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/plugin-ext/src/main/browser/webview/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
********************************************************************************/
import { BaseWidget } from '@theia/core/lib/browser/widgets/widget';
import { BaseWidget, Message } from '@theia/core/lib/browser/widgets/widget';
import { IdGenerator } from '../../../common/id-generator';
import { Disposable, DisposableCollection } from '@theia/core';

Expand Down Expand Up @@ -143,6 +143,11 @@ export class WebviewWidget extends BaseWidget {
this.iframe.contentWindow!.focus();
}

protected onActivateRequest(msg: Message): void {
super.onActivateRequest(msg);
this.node.focus();
}

private reloadFrame() {
if (!this.iframe || !this.iframe.contentDocument || !this.iframe.contentDocument.documentElement) {
return;
Expand Down
13 changes: 9 additions & 4 deletions packages/plugin-ext/src/main/browser/webviews-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ export class WebviewsMainImpl implements WebviewsMain {
this.views.set(viewId, view);
this.shell.addWidget(view, { area: showOptions.area ? showOptions.area : 'main' });
this.shell.activateWidget(view.id);
if (showOptions.preserveFocus) {
view.focus();
}
}
$disposeWebview(handle: string): void {
const view = this.views.get(handle);
Expand All @@ -98,7 +95,15 @@ export class WebviewsMainImpl implements WebviewsMain {
}
}
$reveal(handle: string, showOptions: WebviewPanelShowOptions): void {
throw new Error('Method not implemented.');
const webview = this.getWebview(handle);
if (webview.isDisposed) {
return;
}
if (showOptions.preserveFocus) {
this.shell.revealWidget(webview.id);
} else {
this.shell.activateWidget(webview.id);
}
}
$setTitle(handle: string, value: string): void {
const webview = this.getWebview(handle);
Expand Down