diff --git a/packages/core/src/browser/secondary-window-handler.ts b/packages/core/src/browser/secondary-window-handler.ts index c1929d8a7fa66..32363b116337e 100644 --- a/packages/core/src/browser/secondary-window-handler.ts +++ b/packages/core/src/browser/secondary-window-handler.ts @@ -190,9 +190,8 @@ export class SecondaryWindowHandler { const trackedWidget = this._widgets.find(w => w.id === widgetId); if (trackedWidget && this.getFocusedWindow()) { this.secondaryWindowService.focus(trackedWidget.secondaryWindow!); - return trackedWidget; } - return undefined; + return trackedWidget; } getFocusedWindow(): Window | undefined { diff --git a/packages/core/src/browser/shell/application-shell.ts b/packages/core/src/browser/shell/application-shell.ts index d026cda3b8200..9ca459b0f38d8 100644 --- a/packages/core/src/browser/shell/application-shell.ts +++ b/packages/core/src/browser/shell/application-shell.ts @@ -1358,16 +1358,20 @@ export class ApplicationShell extends Widget { widget = this.rightPanelHandler.activate(id); } if (widget) { - // If this application has focus, then on widget activation, activate the window. - // If this application does not have focus, do not routinely steal focus. - if (this.secondaryWindowHandler.getFocusedWindow()) { - this.windowService.focus(); - } + this.focusWindowIfApplicationFocused(); return widget; } return this.secondaryWindowHandler.activateWidget(id); } + protected focusWindowIfApplicationFocused(): void { + // If this application has focus, then on widget activation, activate the window. + // If this application does not have focus, do not routinely steal focus. + if (this.secondaryWindowHandler.getFocusedWindow()) { + this.windowService.focus(); + } + } + /** * Focus is taken by a widget through the `onActivateRequest` method. It is up to the * widget implementation which DOM element will get the focus. The default implementation @@ -1467,7 +1471,7 @@ export class ApplicationShell extends Widget { widget = this.rightPanelHandler.expand(id); } if (widget) { - this.windowService.focus(); + this.focusWindowIfApplicationFocused(); return widget; } else { return this.secondaryWindowHandler.revealWidget(id);