Commit 4f576f4
Backup: fix file-browser tree-state, indeterminate, and item count
Three related bugs in the modernized file-browser selection:
- Deselecting a row inside a selected subtree only added an exception
but never propagated up. Now walks up: when every loaded child of an
ancestor is effectively deselected, the ancestor is deselected too
(and re-selecting reverses the same walk: when every loaded child
becomes effectively selected, the ancestor follows). Stops at the
first ancestor with un-loaded children.
- Indeterminate only fired for selected folders with a deselected
descendant. Now symmetric: an unselected folder with a selected
descendant also reads as indeterminate (e.g. visitor checks a single
leaf without its ancestors).
- `applySelect` cleared an own-negative entry but didn't add an own
positive, so re-checking a path whose ancestor stayed in `deselected`
would silently inherit unchecked. Now: drop the negative and, only
if removing it wouldn't already leave the row inherited-selected
from an ancestor, add the explicit positive.
- The header "selected" count tracked `selected.size` (the explicit
positives), which never grew as the visitor expanded an inherited
subtree. Now hoists loaded folder children to the FileBrowser via a
per-row callback and counts effectively-selected leaves only: a file
counts as 1, a folder counts as 1 only when its contents haven't
been loaded yet (otherwise the server treats it as one opaque
download unit), and indeterminate folders contribute only the
effectively-selected descendants underneath. BackupDetail reads the
same count for its Download / Restore action labels via a new
`onSelectionCountChange` callback, and the labels switch to proper
singular/plural via `_n()`.
`useMockFileTree` no longer seeds non-null callers with the root tree
on first render — the seeding leaked the root tree into closed
NodeRows' `children` state and let the registerChildren effect
accidentally register MOCK_FILE_TREE for non-root paths during the
window between "open clicked" and "fetch resolved", which infinitely
recursed the count walk. FileBrowser now imports `MOCK_FILE_TREE`
directly for its roots; the hook handles only lazy non-root loads.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent f69d275 commit 4f576f4
3 files changed
Lines changed: 376 additions & 109 deletions
File tree
- projects/packages/backup/src/dashboard
- components
- backup-detail
- file-browser
- hooks
Lines changed: 18 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
31 | | - | |
| 30 | + | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
| 40 | + | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
49 | | - | |
| 48 | + | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
112 | 113 | | |
113 | 114 | | |
114 | 115 | | |
| 116 | + | |
115 | 117 | | |
116 | 118 | | |
117 | 119 | | |
| |||
0 commit comments