Fix tha activateById on side panels widgets

pull/6487/head
Nicolas Brichet 4 years ago committed by foo
parent ab7b0ad38d
commit e2ed555dbf

@ -637,7 +637,6 @@ const sidebarVisibility: JupyterFrontEndPlugin<void> = {
case 'left':
if (notebookShell.leftCollapsed) {
notebookShell.activateById(args['id'] as string);
notebookShell.expandLeft();
} else {
notebookShell.collapseLeft();
if (notebookShell.currentWidget) {
@ -648,7 +647,6 @@ const sidebarVisibility: JupyterFrontEndPlugin<void> = {
case 'right':
if (notebookShell.rightCollapsed) {
notebookShell.activateById(args['id'] as string);
notebookShell.expandRight();
} else {
notebookShell.collapseRight();
if (notebookShell.currentWidget) {

@ -232,7 +232,13 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
const widget = find(this.widgets(area), w => w.id === id);
if (widget) {
widget.activate();
if (area === 'left') {
if (this.leftCollapsed) this.expandLeft(id);
else this.collapseLeft();
} else if (area === 'right') {
if (this.rightCollapsed) this.expandRight(id);
else this.collapseRight();
} else widget.activate();
}
}
}
@ -323,12 +329,12 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
/**
* Expand the left panel to show the sidebar with its widget.
*/
expandLeft(): void {
expandLeft(id?: string): void {
if (!this.sidePanelsVisible()) {
throw new Error('Left panel is not available on this page');
}
this.leftPanel.show();
this._leftHandler.expand(); // Show the current widget, if any
this._leftHandler.expand(id); // Show the current widget, if any
this._onLayoutModified();
}
@ -347,12 +353,12 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell {
/**
* Expand the right panel to show the sidebar with its widget.
*/
expandRight(): void {
expandRight(id?: string): void {
if (!this.sidePanelsVisible()) {
throw new Error('Right panel is not available on this page');
}
this.rightPanel.show();
this._rightHandler.expand(); // Show the current widget, if any
this._rightHandler.expand(id); // Show the current widget, if any
this._onLayoutModified();
}
@ -594,11 +600,14 @@ namespace Private {
* This will open the most recently used widget, or the first widget
* if there is no most recently used.
*/
expand(): void {
const visibleWidget = this.current;
if (visibleWidget) {
this._current = visibleWidget;
this.activate(visibleWidget.id);
expand(id?: string): void {
if (id) this.activate(id);
else {
const visibleWidget = this.current;
if (visibleWidget) {
this._current = visibleWidget;
this.activate(visibleWidget.id);
}
}
}

Loading…
Cancel
Save