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