From eaecf563ff3e5c9dbbec9042273301515f64c548 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Padez?= Date: Sat, 29 Aug 2026 09:15:36 +0100 Subject: [PATCH] Back and Forward move between folders MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the folder param was written with `replace`, on my argument that browsing is not navigation worth a history entry. that was wrong, and the URL itself gives it away: the moment a folder is ADDRESSABLE it is a place, and Back meaning "the folder I was just in" is what anybody expects of a place. it also matches /files, which pushes. an embedded browser behaving differently from the full one is a difference nobody can see a reason for — and would be discovered by trying it, which is exactly how this was. reading needed nothing: `currentPath` is derived from the param, so a Back that rewrites the query moves the browser with it. Co-Authored-By: Claude Opus 5 Officer-Session: 656f5c85-e49a-4f1f-b9f3-042a04b4d043 --- .../FileBrowserApp/useFileBrowserApp.ts | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/useFileBrowserApp.ts b/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/useFileBrowserApp.ts index 590717d2..657df1f1 100644 --- a/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/useFileBrowserApp.ts +++ b/src/workspaces/officerdev/src/apps/FileBrowser/FileBrowserApp/useFileBrowserApp.ts @@ -109,19 +109,27 @@ export const useFileBrowserApp = ( // which is the distinction a wholesale reset kept getting wrong. if (urlPath) navigate({ pathname: folderHref(path), search: withoutViewerParams(location.search) }); else if (pathParam) { - setSearchParams( - (prev) => { - const next = new URLSearchParams(withoutViewerParams(prev.toString())); - // The base folder is the ABSENCE of the param, so a link to the top of an embedded browser is - // the plain screen URL and nothing accumulates for having gone nowhere. - const relative = path.startsWith(basePath) ? path.slice(basePath.replace(/\/$/, '').length + 1) : ''; - if (!relative) next.delete(pathParam); - else next.set(pathParam, relative); - return next; - }, - // Browsing folders is not navigation anybody wants twenty back-button presses of. - { replace: true }, - ); + /* + PUSHED, not replaced — so Back and Forward move between folders. + + This was `replace` on the argument that browsing is not navigation worth a history entry. That + was wrong, and wrong in a way the URL itself gives away: the moment a folder is addressable, it + is a place, and Back meaning "the folder I was just in" is what anybody expects of a place. It + also matches `/files`, which pushes — an embedded browser behaving differently from the full one + is a difference nobody can see a reason for. + + Reading is unchanged: `currentPath` is derived from the param, so a Back that rewrites the query + moves the browser with it and needs nothing here. + */ + setSearchParams((prev) => { + const next = new URLSearchParams(withoutViewerParams(prev.toString())); + // The base folder is the ABSENCE of the param, so a link to the top of an embedded browser is + // the plain screen URL and nothing accumulates for having gone nowhere. + const relative = path.startsWith(basePath) ? path.slice(basePath.replace(/\/$/, '').length + 1) : ''; + if (!relative) next.delete(pathParam); + else next.set(pathParam, relative); + return next; + }); } else { setLocalPath(path); // Written here rather than in an effect on `currentPath`, so it records a NAVIGATION and not the