From da07048f5379f204255a0bc45c6c29ce93e994cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Mon, 7 Sep 2026 14:06:46 +0100 Subject: [PATCH] FileBrowser can report the folder it is showing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A chooser whose answer is a folder had no way to ask. Folders navigate rather than being pickable — getting to a file requires it — so the only way to say "this one" is to be standing in it, and the caller needs to know which one that is to put a button on it. Reported from the component rather than threaded through the hook: the hook's job is the folder, and a seventh positional argument is how a signature stops being readable. --- .../FileBrowserApp/FileBrowserApp.tsx | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/FileBrowserApp.tsx b/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/FileBrowserApp.tsx index cf53d1b9..461fbc23 100644 --- a/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/FileBrowserApp.tsx +++ b/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/FileBrowserApp.tsx @@ -1,3 +1,4 @@ +import { useEffect, useRef } from 'react'; import { Breadcrumb } from './components/Breadcrumb'; import { Toolbar } from './components/Toolbar'; import { UploadProgress } from './components/UploadProgress'; @@ -35,6 +36,14 @@ type FileBrowserAppProps = { * handling reimplemented, all of it free to drift from the real browser. */ onPickFile?: (file: PickedFile) => void; + /** + * The folder being shown, whenever it changes. + * + * For a chooser whose answer is a FOLDER rather than a file. Folders navigate rather than being + * pickable — getting to a file requires it — so the only way to say "this one" is to be standing in + * it, and the caller needs to know which one that is to put a button on it. + */ + onPathChange?: (path: string) => void; }; export const FileBrowserApp = ({ @@ -45,9 +54,18 @@ export const FileBrowserApp = ({ panelId, pathParam, onPickFile, + onPathChange, }: FileBrowserAppProps) => { const fileBrowserManager = useFileBrowserApp(basePath, rootOverride, urlPath, panelId, pathParam, onPickFile); - const { handleNavigate } = fileBrowserManager; + const { handleNavigate, currentPath } = fileBrowserManager; + + // Reported from here rather than threaded through the hook: the hook's job is the folder, and one + // more positional argument on a six-argument call is how a signature stops being readable. + const report = useRef(onPathChange); + report.current = onPathChange; + useEffect(() => { + report.current?.(currentPath); + }, [currentPath]); return (