Skip to content

Commit 2950042

Browse files
committed
Fix tha activateById on side panels widgets
1 parent 844154f commit 2950042

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

packages/application-extension/src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,6 @@ const sidebarVisibility: JupyterFrontEndPlugin<void> = {
636636
case 'left':
637637
if (notebookShell.leftCollapsed) {
638638
notebookShell.activateById(args['id'] as string);
639-
notebookShell.expandLeft();
640639
} else {
641640
notebookShell.collapseLeft();
642641
if (notebookShell.currentWidget) {
@@ -647,7 +646,6 @@ const sidebarVisibility: JupyterFrontEndPlugin<void> = {
647646
case 'right':
648647
if (notebookShell.rightCollapsed) {
649648
notebookShell.activateById(args['id'] as string);
650-
notebookShell.expandRight();
651649
} else {
652650
notebookShell.collapseRight();
653651
if (notebookShell.currentWidget) {

packages/application/src/shell.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,13 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
232232

233233
const widget = find(this.widgets(area), w => w.id === id);
234234
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();
236242
}
237243
}
238244
}
@@ -304,12 +310,12 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
304310
/**
305311
* Expand the left panel to show the sidebar with its widget.
306312
*/
307-
expandLeft(): void {
313+
expandLeft(id?: string): void {
308314
if (!this.sidePanelsVisible()) {
309315
throw new Error('Left panel is not available on this page');
310316
}
311317
this.leftPanel.show();
312-
this._leftHandler.expand(); // Show the current widget, if any
318+
this._leftHandler.expand(id); // Show the current widget, if any
313319
this._onLayoutModified();
314320
}
315321

@@ -328,12 +334,12 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
328334
/**
329335
* Expand the right panel to show the sidebar with its widget.
330336
*/
331-
expandRight(): void {
337+
expandRight(id?: string): void {
332338
if (!this.sidePanelsVisible()) {
333339
throw new Error('Right panel is not available on this page');
334340
}
335341
this.rightPanel.show();
336-
this._rightHandler.expand(); // Show the current widget, if any
342+
this._rightHandler.expand(id); // Show the current widget, if any
337343
this._onLayoutModified();
338344
}
339345

@@ -583,11 +589,14 @@ namespace Private {
583589
* This will open the most recently used widget, or the first widget
584590
* if there is no most recently used.
585591
*/
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+
}
591600
}
592601
}
593602

0 commit comments

Comments
 (0)