@@ -182,6 +182,7 @@ export class SessionWindow implements IDisposable {
182182 } ) ;
183183 this . _window . on ( 'blur' , ( ) => {
184184 titleBarView . deactivate ( ) ;
185+ this . _hideEnvSelectPopup ( ) ;
185186 } ) ;
186187
187188 titleBarView . load ( ) ;
@@ -192,12 +193,16 @@ export class SessionWindow implements IDisposable {
192193 // this._labView freshly means an env switch that recreates the labView cannot
193194 // leave a stale, disposed webContents behind, nor accumulate a handler per switch.
194195 this . _window . webContents . on ( 'focus' , ( ) => {
195- const wc = this . _labView ?. view ?. webContents ;
196- if ( wc && ! wc . isDestroyed ( ) ) wc . focus ( ) ;
196+ const wc = this . contentView ?. webContents ;
197+ if ( wc && ! wc . isDestroyed ( ) ) {
198+ wc . focus ( ) ;
199+ }
197200 } ) ;
198201 this . _titleBarView . view . webContents . on ( 'focus' , ( ) => {
199- const wc = this . _labView ?. view ?. webContents ;
200- if ( wc && ! wc . isDestroyed ( ) ) wc . focus ( ) ;
202+ const wc = this . contentView ?. webContents ;
203+ if ( wc && ! wc . isDestroyed ( ) ) {
204+ wc . focus ( ) ;
205+ }
201206 } ) ;
202207
203208 if ( this . _contentViewType === ContentViewType . Lab ) {
@@ -242,12 +247,15 @@ export class SessionWindow implements IDisposable {
242247 this . _resizeViewsDelayed ( ) ;
243248 } ) ;
244249 this . _window . on ( 'maximize' , ( ) => {
250+ this . _titleBarView . setMaximized ( this . _window . isMaximized ( ) ) ;
245251 this . _resizeViewsDelayed ( ) ;
246252 } ) ;
247253 this . _window . on ( 'unmaximize' , ( ) => {
254+ this . _titleBarView . setMaximized ( this . _window . isMaximized ( ) ) ;
248255 this . _resizeViewsDelayed ( ) ;
249256 } ) ;
250257 this . _window . on ( 'restore' , ( ) => {
258+ this . _titleBarView . setMaximized ( this . _window . isMaximized ( ) ) ;
251259 this . _resizeViewsDelayed ( ) ;
252260 } ) ;
253261 this . _window . on ( 'move' , ( ) => {
@@ -394,7 +402,9 @@ export class SessionWindow implements IDisposable {
394402 this . _window . contentView . addChildView ( labView . view ) ;
395403
396404 labView . view . webContents . on ( 'did-finish-load' , ( ) => {
397- labView . view . webContents . focus ( ) ;
405+ if ( this . _window . isFocused ( ) ) {
406+ labView . view . webContents . focus ( ) ;
407+ }
398408 } ) ;
399409
400410 labView . load ( ( errorCode : number , errorDescription : string ) => {
@@ -1376,18 +1386,23 @@ export class SessionWindow implements IDisposable {
13761386 }
13771387
13781388 const titleBarRect = this . _titleBarView . view . getBounds ( ) ;
1379- const popupWidth = 600 ;
13801389 const paddingRight = process . platform === 'darwin' ? 33 : 127 ;
1390+ // Anchor the popup's right edge near the env button and cap its width to
1391+ // what fits, so on a narrow window it shrinks (the popup content is
1392+ // responsive) instead of hanging off an edge with the search box or the
1393+ // env list clipped.
1394+ const rightEdge = titleBarRect . width - paddingRight ;
1395+ const popupWidth = Math . min ( 600 , rightEdge ) ;
13811396 // shorten browser view height if larger than max allowed
13821397 const maxHeight = Math . min (
13831398 this . _envSelectPopup . getScrollHeight ( ) ,
13841399 defaultEnvSelectPopupHeight
13851400 ) ;
13861401
13871402 this . _envSelectPopup . view . view . setBounds ( {
1388- x : Math . round ( titleBarRect . width - paddingRight - popupWidth ) ,
1403+ x : Math . round ( rightEdge - popupWidth ) ,
13891404 y : Math . round ( titleBarRect . height ) ,
1390- width : popupWidth ,
1405+ width : Math . round ( popupWidth ) ,
13911406 height : Math . round ( maxHeight )
13921407 } ) ;
13931408 }
0 commit comments