From d9b4ca29b8149d5d6abdeddfd58b187692a124e5 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Thu, 25 Jan 2024 21:53:07 +0000 Subject: [PATCH 1/2] Workaround for the file browser tracker focus issue --- packages/tree-extension/src/index.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/tree-extension/src/index.ts b/packages/tree-extension/src/index.ts index a4b58ad829..b3cf033e5e 100644 --- a/packages/tree-extension/src/index.ts +++ b/packages/tree-extension/src/index.ts @@ -18,6 +18,7 @@ import { FileBrowser, Uploader, IDefaultFileBrowser, + IFileBrowserFactory, } from '@jupyterlab/filebrowser'; import { ISettingRegistry } from '@jupyterlab/settingregistry'; @@ -263,6 +264,7 @@ const notebookTreeWidget: JupyterFrontEndPlugin = { ITranslator, ISettingRegistry, IToolbarWidgetRegistry, + IFileBrowserFactory, ], optional: [ IRunningSessionManagers, @@ -277,6 +279,7 @@ const notebookTreeWidget: JupyterFrontEndPlugin = { translator: ITranslator, settingRegistry: ISettingRegistry, toolbarRegistry: IToolbarWidgetRegistry, + factory: IFileBrowserFactory, manager: IRunningSessionManagers | null, settingEditorTracker: ISettingEditorTracker | null, jsonSettingEditorTracker: IJSONSettingEditorTracker | null @@ -381,6 +384,19 @@ const notebookTreeWidget: JupyterFrontEndPlugin = { } ); + const { tracker } = factory; + + // TODO: remove + // Workaround to force the focus on the default file browser + // See https://github.com/jupyterlab/jupyterlab/issues/15629 for more info + const setCurrentToDefaultBrower = () => { + tracker['_pool'].current = browser; + }; + + tracker.widgetAdded.connect((sender, widget) => + setCurrentToDefaultBrower() + ); + return nbTreeWidget; }, }; From ba83fc51df489dc97c5a22b746dbd6c7db015249 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Thu, 25 Jan 2024 21:55:43 +0000 Subject: [PATCH 2/2] fix missing default --- packages/tree-extension/src/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/tree-extension/src/index.ts b/packages/tree-extension/src/index.ts index b3cf033e5e..4d9ba65e7a 100644 --- a/packages/tree-extension/src/index.ts +++ b/packages/tree-extension/src/index.ts @@ -397,6 +397,8 @@ const notebookTreeWidget: JupyterFrontEndPlugin = { setCurrentToDefaultBrower() ); + setCurrentToDefaultBrower(); + return nbTreeWidget; }, };