closing a file no longer sends you home
Open ~/Tests, double-click a file, edit it, save, close the pane — and the browser
was back at ~. Reported from a real session, not found by reading.
`onCloseViewer` was `setSearchParams({})`, which wipes the WHOLE query string. The
folder lives in `?path=`, so closing the viewer deleted where you were along with
what was on top of it. It also discarded anything `useGlobalQueryString` had put
in the URL.
The rule was already written down one file away, in
`useFileBrowserApp.setViewerParams`: "`path` is not one of them — it is where you
are, not what is on top of it — so it survives." Only the OPEN path honoured it.
Close now deletes the ephemeral keys by name, which is exactly what
`onCloseEphemeral`, `onCloseEphemeral2` and `onCloseChat` directly below it have
always done — it was the single outlier among four handlers.
Checked the other exits before calling it fixed: there is one `onClose` wired to
the viewer, every other handler already used the targeted form, and the
mount-cleanup effect deletes the same keys off `prev` rather than replacing the
string. This was the only wholesale wipe in the repo.
tsgo clean, frontend builds, 817 pass / 7 fail unchanged.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -51,7 +51,27 @@ export const useFileViewerPanels = (): EphemeralPanels | null => {
|
|||||||
? viewerWithEphemeralLayout
|
? viewerWithEphemeralLayout
|
||||||
: singleViewerLayout;
|
: singleViewerLayout;
|
||||||
|
|
||||||
const onCloseViewer = useCallback(() => setSearchParams({}), [setSearchParams]);
|
/**
|
||||||
|
* Close the viewer and everything stacked on it — and NOTHING else.
|
||||||
|
*
|
||||||
|
* This was `setSearchParams({})`, which wiped the whole query string. That took `path` with it, so
|
||||||
|
* closing a file you had opened inside a folder dropped you back at home: open ~/Tests, view a file,
|
||||||
|
* close it, and the browser is at ~. It also discarded whatever `useGlobalQueryString` had put there.
|
||||||
|
*
|
||||||
|
* The intent was already written down in `useFileBrowserApp.setViewerParams` — "`path` is not one of
|
||||||
|
* them, it is where you are, not what is on top of it, so it survives" — but only the OPEN path
|
||||||
|
* honoured it. Deleting the ephemeral keys by name is the same rule applied to close, and it is what
|
||||||
|
* `onCloseEphemeral` directly below has always done.
|
||||||
|
*/
|
||||||
|
const onCloseViewer = useCallback(
|
||||||
|
() =>
|
||||||
|
setSearchParams((prev) => {
|
||||||
|
const next = new URLSearchParams(prev);
|
||||||
|
EPHEMERAL_KEYS.forEach((k) => next.delete(k));
|
||||||
|
return next;
|
||||||
|
}),
|
||||||
|
[setSearchParams],
|
||||||
|
);
|
||||||
|
|
||||||
const onCloseEphemeral = useCallback(
|
const onCloseEphemeral = useCallback(
|
||||||
() =>
|
() =>
|
||||||
|
|||||||
Reference in New Issue
Block a user