@@ -49,6 +49,7 @@ import { AuxiliaryBarPart } from 'vs/workbench/browser/parts/auxiliarybar/auxili
49
49
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
50
50
import { IAuxiliaryWindowService } from 'vs/workbench/services/auxiliaryWindow/browser/auxiliaryWindowService' ;
51
51
import { mainWindow } from 'vs/base/browser/window' ;
52
+ import { IPaneComposite } from 'vs/workbench/common/panecomposite' ;
52
53
53
54
//#region Layout Implementation
54
55
@@ -1083,18 +1084,43 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
1083
1084
this . _register ( delegate . onDidChangeNotificationsVisibility ( visible => this . _onDidChangeNotificationsVisibility . fire ( visible ) ) ) ;
1084
1085
}
1085
1086
1086
- hasFocus ( part : Parts ) : boolean {
1087
+ hasFocus ( part : Parts , viewContainerId ?: string ) : boolean {
1087
1088
const container = this . getContainer ( getActiveWindow ( ) , part ) ;
1088
1089
if ( ! container ) {
1089
1090
return false ;
1090
1091
}
1091
1092
1092
- const activeElement = container . ownerDocument . activeElement ;
1093
+ const activeElement = document . activeElement ;
1093
1094
if ( ! activeElement ) {
1094
1095
return false ;
1095
1096
}
1096
1097
1097
- return isAncestorUsingFlowTo ( activeElement , container ) ;
1098
+ const activePanel = this . getFocusWebviewPart ( part ) ;
1099
+ if ( viewContainerId && viewContainerId === activePanel ?. getId ( ) ) {
1100
+ return true ;
1101
+ }
1102
+
1103
+ return ! ! container && isAncestorUsingFlowTo ( activeElement , container ) ;
1104
+ }
1105
+
1106
+ getFocusWebviewPart ( part : Parts ) : IPaneComposite | undefined {
1107
+ let focusPart : IPaneComposite | undefined ;
1108
+ // only these two part will combine webview view container
1109
+ switch ( part ) {
1110
+ case Parts . PANEL_PART : {
1111
+ focusPart = this . paneCompositeService . getActivePaneComposite ( ViewContainerLocation . Panel ) ;
1112
+ break ;
1113
+ }
1114
+ case Parts . SIDEBAR_PART : {
1115
+ focusPart = this . paneCompositeService . getActivePaneComposite ( ViewContainerLocation . Sidebar ) ;
1116
+ break ;
1117
+ }
1118
+ case Parts . AUXILIARYBAR_PART : {
1119
+ focusPart = this . paneCompositeService . getActivePaneComposite ( ViewContainerLocation . AuxiliaryBar ) ;
1120
+ break ;
1121
+ }
1122
+ }
1123
+ return focusPart ;
1098
1124
}
1099
1125
1100
1126
focusPart ( part : MULTI_WINDOW_PARTS , targetWindow : Window ) : void ;
@@ -1104,7 +1130,6 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
1104
1130
if ( container ) {
1105
1131
focusWindow ( container ) ;
1106
1132
}
1107
-
1108
1133
switch ( part ) {
1109
1134
case Parts . EDITOR_PART :
1110
1135
this . editorGroupService . getPart ( container ) . activeGroup . focus ( ) ;
0 commit comments