From 5d265b90ed5f097af4ca22d283ecdc705229ff92 Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Fri, 26 Jan 2024 10:55:05 +0100 Subject: [PATCH] Workaround for the file browser tracker focus issue (#7224) * Workaround for the file browser tracker focus issue * fix missing default --- packages/tree-extension/src/index.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/tree-extension/src/index.ts b/packages/tree-extension/src/index.ts index a4b58ad829..4d9ba65e7a 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,21 @@ 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() + ); + + setCurrentToDefaultBrower(); + return nbTreeWidget; }, };