diff --git a/docker/frontend/src/Library.tsx b/docker/frontend/src/Library.tsx index d668a4f..44d9af0 100644 --- a/docker/frontend/src/Library.tsx +++ b/docker/frontend/src/Library.tsx @@ -1637,8 +1637,11 @@ function Catalogue() { }} > {rows.map((n) => { - const rootKey = n.key.split('/')[0]; - const folder = folders.find((f) => (f.name || '').replace(/\\/g, '/') === rootKey || f.name === rootKey) ?? null; + const folder = + folders.find((f) => { + const fNorm = (f.name || '').replace(/\\/g, '/'); + return n.key === fNorm || n.key.startsWith(`${fNorm}/`) || n.key === f.name || n.key.startsWith(`${f.name}/`); + }) ?? folders[0] ?? null; // The row that says a reading is under way is the folder the // reading stands in — not the folder it was pointed at, which // would be the same row for the whole of an afternoon while @@ -1697,21 +1700,19 @@ function Catalogue() { // right-clicks. Shift+F10 raises the same event, which is // the keyboard's way in. onContextMenu={(e) => { - if (!folder) return; e.preventDefault(); - const box = e.currentTarget.getBoundingClientRect(); - // The row's own path under the picked folder, '' for - // the picked folder itself — what a scan started from - // here would be kept to. Spelled the way the walk - // spells it, trailing slash and all. - const under = n.key.slice(folder.name.length + 1); + e.stopPropagation(); + const targetFolder = folder || folders[0]; + if (!targetFolder) return; + const fNorm = (targetFolder.name || '').replace(/\\/g, '/'); + const sub = n.key.length > fNorm.length ? n.key.slice(fNorm.length + 1) : ''; setMenu({ - folder, + folder: targetFolder, root: n.depth === 0, - rel: under ? `${under}/` : '', + rel: sub ? `${sub}/` : '', node: n.key, - x: Math.min(e.clientX || box.left, window.innerWidth - 150), - y: Math.min(e.clientY || box.top, window.innerHeight - 150), + x: Math.min(e.clientX, window.innerWidth - 160), + y: Math.min(e.clientY, window.innerHeight - 200), }); }} >