@@ -232,7 +232,13 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
232
232
233
233
const widget = find ( this . widgets ( area ) , w => w . id === id ) ;
234
234
if ( widget ) {
235
- widget . activate ( ) ;
235
+ if ( area === 'left' ) {
236
+ if ( this . leftCollapsed ) this . expandLeft ( id ) ;
237
+ else this . collapseLeft ( ) ;
238
+ } else if ( area === 'right' ) {
239
+ if ( this . rightCollapsed ) this . expandRight ( id ) ;
240
+ else this . collapseRight ( ) ;
241
+ } else widget . activate ( ) ;
236
242
}
237
243
}
238
244
}
@@ -304,12 +310,12 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
304
310
/**
305
311
* Expand the left panel to show the sidebar with its widget.
306
312
*/
307
- expandLeft ( ) : void {
313
+ expandLeft ( id ?: string ) : void {
308
314
if ( ! this . sidePanelsVisible ( ) ) {
309
315
throw new Error ( 'Left panel is not available on this page' ) ;
310
316
}
311
317
this . leftPanel . show ( ) ;
312
- this . _leftHandler . expand ( ) ; // Show the current widget, if any
318
+ this . _leftHandler . expand ( id ) ; // Show the current widget, if any
313
319
this . _onLayoutModified ( ) ;
314
320
}
315
321
@@ -328,12 +334,12 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
328
334
/**
329
335
* Expand the right panel to show the sidebar with its widget.
330
336
*/
331
- expandRight ( ) : void {
337
+ expandRight ( id ?: string ) : void {
332
338
if ( ! this . sidePanelsVisible ( ) ) {
333
339
throw new Error ( 'Right panel is not available on this page' ) ;
334
340
}
335
341
this . rightPanel . show ( ) ;
336
- this . _rightHandler . expand ( ) ; // Show the current widget, if any
342
+ this . _rightHandler . expand ( id ) ; // Show the current widget, if any
337
343
this . _onLayoutModified ( ) ;
338
344
}
339
345
@@ -583,11 +589,14 @@ namespace Private {
583
589
* This will open the most recently used widget, or the first widget
584
590
* if there is no most recently used.
585
591
*/
586
- expand ( ) : void {
587
- const visibleWidget = this . current ;
588
- if ( visibleWidget ) {
589
- this . _current = visibleWidget ;
590
- this . activate ( visibleWidget . id ) ;
592
+ expand ( id ?: string ) : void {
593
+ if ( id ) this . activate ( id ) ;
594
+ else {
595
+ const visibleWidget = this . current ;
596
+ if ( visibleWidget ) {
597
+ this . _current = visibleWidget ;
598
+ this . activate ( visibleWidget . id ) ;
599
+ }
591
600
}
592
601
}
593
602
0 commit comments