web: fold all keeps the top-level row open

COLLAPSE ALL folded the top-level row as well, and that row is already its own
fold: one click on its name shuts it and takes the whole subtree with it. Folding
it from the menu hid every row of the tree — the item repeated a click the reader
already had, while the one thing a click there cannot reach, the folders nested
below, was the part that got lost with it.

So the item folds the folders nested below the top level: every row with a
subfolder under it that is not itself a folder picked at the top level. The
top-level row stays drawn and stays open, its own subfolders are drawn folded,
and no top-level row ever leaves the column. `nested` is computed off `parents`
once, and the item is disabled on a folder with nothing nested under it.

Verified:
  library-check.mjs — 35 steps, all passed. The fold step now reads the rows the
    click leaves behind instead of a row count: the fully open roll (4 rows)
    becomes exactly CheckRoll aria-expanded=true, CheckRoll/2026
    aria-expanded=false, CheckRoll/Empty (a leaf, so no aria-expanded) —
    CheckRoll/2026/04 is away, the top-level row is not — with the strip's 2
    tiles unmoved and the row menu still leading with lib-menu-collapse.
  frontend tsc --noEmit clean. Live 8090 on index-DAIpyDNV.js matching dist/:
  /, /library and /app 200 with 0 console errors.

ponytail: with several folders picked, one COLLAPSE ALL folds the nested rows of
all of them, not only the row that was clicked — no top-level row is hidden
either way; scope it to the clicked folder's prefix when a column routinely
holds many picked folders.
This commit is contained in:
2026-09-28 21:23:56 +07:00
parent 4a740b1e28
commit 5e28b42067
2 changed files with 31 additions and 33 deletions
+16 -23
View File
@@ -374,11 +374,12 @@ await page.keyboard.press('Escape');
step('escape closes the folder menu too', (await page.$('[data-key="lib-menu"]')) === null);
// The head of the tree is the whole tree's control: a right click on the column's
// own name folds every row that has something under it, so a roll read to the
// bottom of its dates comes back to its own line. The frames in the strip are the
// strip's business and do not move with it. The subfolder opened above carries a
// fold of its own, so it is opened first: the claim is what ONE click does to
// every row at once, not to the one that was already shut.
// own name, or on the row of a folder picked at the top level, folds the folders
// nested below the top level. The top-level row itself stays open — one click on
// its name already shuts it, so the menu item would only repeat that click — and
// the frames in the strip are the strip's business and do not move with the rows.
// The subfolder opened above carries a fold of its own, so it is opened first:
// the claim is what ONE click does to every row at once, not to one already shut.
await page.click('[data-key="lib-node-CheckRoll/2026"]');
await page.waitForFunction(() => document.querySelectorAll('[data-key^="lib-node-"]').length === 4, null, {
timeout: 10_000,
@@ -407,29 +408,21 @@ step(
await page.getAttribute('[data-key="lib-root-name"]', 'title')
);
await page.click('[data-key="lib-menu-collapse"]');
await page.waitForFunction(() => document.querySelectorAll('[data-key^="lib-node-"]').length === 1, null, {
timeout: 10_000,
polling: 50,
});
const flatTiles = await page.$$eval(thumbs, (els) => els.length);
const shutRoot = await page.getAttribute('[data-key="lib-node-CheckRoll"]', 'aria-expanded');
// Opening the root back up is the ruler for the rest: only the rows the fold shut
// are still away, and the subfolder two deep is one of them.
await page.click('[data-key="lib-node-CheckRoll"]');
await page.waitForFunction(() => document.querySelectorAll('[data-key^="lib-node-"]').length === 3, null, {
timeout: 10_000,
polling: 50,
});
const revealed = await page.$$eval('[data-key^="lib-node-"]', (els) => els.map((e) => e.dataset.key));
step(
'and one click folds every row that has something under it',
deepRows === 4 && shutRoot === 'false' && flatTiles === deepTiles && revealed.join(',') === 'lib-node-CheckRoll,lib-node-CheckRoll/2026,lib-node-CheckRoll/Empty',
`${deepRows} rows → 1, ${revealed.length} back with the root opened, ${flatTiles} tiles kept`,
const flatTiles = await page.$$eval(thumbs, (els) => els.length);
const ended = await page.$$eval('[data-key^="lib-node-"]', (els) =>
els.map((e) => `${e.dataset.key}:${e.getAttribute('aria-expanded') ?? '-'}`)
);
step(
'and one click folds the subfolders, leaving the top-level row open',
deepRows === 4 &&
flatTiles === deepTiles &&
ended.join(' ') === 'lib-node-CheckRoll:true lib-node-CheckRoll/2026:false lib-node-CheckRoll/Empty:-',
`${deepRows} rows → ${ended.length}, ${ended.join(' ')}, ${flatTiles} tiles kept`,
);
// The open folder is the visit's, not the fold's, so it is put back where the
// sections below left it.
await page.click('[data-key="lib-node-CheckRoll/2026"]');
await page.waitForFunction((sel) => document.querySelectorAll(sel).length === 2, thumbs, { timeout: 30_000 });
// The divider drags the column, and what the visit leaves behind — the width the
// column was left at and the folder that was open — is what the next visit opens