From 069685085bcfb89596a96163b96de302ea38649f Mon Sep 17 00:00:00 2001 From: Nicolas Brichet Date: Fri, 26 Aug 2022 17:12:14 +0200 Subject: [PATCH] Fix the sidebar closing if another widget is selected in the same sidebar --- packages/application-extension/src/index.ts | 8 ++++++-- packages/application/src/shell.ts | 15 +++++---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/application-extension/src/index.ts b/packages/application-extension/src/index.ts index dbe8e854c..2ccf887a0 100644 --- a/packages/application-extension/src/index.ts +++ b/packages/application-extension/src/index.ts @@ -651,7 +651,9 @@ const sidebarVisibility: JupyterFrontEndPlugin = { switch (args['side'] as string) { case 'left': if (notebookShell.leftCollapsed) { - notebookShell.activateById(args['id'] as string); + notebookShell.expandLeft(args.id as string); + } else if (notebookShell.leftHandler.current?.id !== args.id) { + notebookShell.expandLeft(args.id as string); } else { notebookShell.collapseLeft(); if (notebookShell.currentWidget) { @@ -661,7 +663,9 @@ const sidebarVisibility: JupyterFrontEndPlugin = { break; case 'right': if (notebookShell.rightCollapsed) { - notebookShell.activateById(args['id'] as string); + notebookShell.expandRight(args.id as string); + } else if (notebookShell.rightHandler.current?.id !== args.id) { + notebookShell.expandRight(args.id as string); } else { notebookShell.collapseRight(); if (notebookShell.currentWidget) { diff --git a/packages/application/src/shell.ts b/packages/application/src/shell.ts index c142ba092..9442150f6 100644 --- a/packages/application/src/shell.ts +++ b/packages/application/src/shell.ts @@ -209,17 +209,9 @@ export class NotebookShell extends Widget implements JupyterFrontEnd.IShell { const widget = find(this.widgets(area), w => w.id === id); if (widget) { if (area === 'left') { - if (this.leftCollapsed) { - this.expandLeft(id); - } else { - this.collapseLeft(); - } + this.expandLeft(id); } else if (area === 'right') { - if (this.rightCollapsed) { - this.expandRight(id); - } else { - this.collapseRight(); - } + this.expandRight(id); } else { widget.activate(); } @@ -628,6 +620,9 @@ namespace Private { * if there is no most recently used. */ expand(id?: string): void { + if (this._current) { + this.collapse(); + } if (id) { this.activate(id); } else {