Commit c335783
authored
fix(layers): keep nested groups in order and movable inside their parent (#1744)
* fix(layers): keep nested groups in order and movable inside their parent
The #1739 fix gave every empty folder a position, but derived it from the
nearest group in array order and, for a nested folder, from the end of its
parent's range. Neither reads as a sibling, so as soon as one child of a
group gained a layer its sibling folders were placed against the wrong
block: a nested folder could be pushed past an unrelated top-level group
and out of the parent it belongs to, and "move up"/"move down" on a nested
group reported a change while the panel snapped straight back.
Panel order now anchors an unpositioned group on its *siblings* — the
groups sharing its parent — whose ranges span their whole subtrees. An
ancestor's range already contains the slot being chosen and an unrelated
group's covers a different branch, so neither can place it; with no
sibling positioned yet a nested folder falls to the end of its parent's
block and a top-level one to the top of the panel.
Reordering follows the same shape: a group steps over a whole neighbouring
sibling block instead of one unit at a time into it, and the edge of its
parent is a wall, so a nested group moves among its siblings only and the
menu greys out at the first and last child. A top-level group now clears
a neighbouring subtree in one move rather than landing inside it.
Group headers all come from one core walk (layerPanelGroupHeaders,
replacing placeUnpositionedGroups), so the group a row belongs to, the
organizers above it, and the empty folders are emitted parents-first
against the same anchors. That is what keeps a nested folder below the
parent it sits in, and it drops the panel's duplicate anchor logic.
* Address CodeRabbit review feedback
- Correct the reorder docs about the parent boundary. CodeRabbit read
moveGroupThroughUnits as letting a nested group move across layers its
parent owns directly, and proposed rejecting that move. The observation
is right but the move is not a defect: those rows are one more block
inside the parent, so ordering a child against them is a real reorder,
and the group still cannot cross the parent's boundary. Rejecting it
would leave no way to order a child folder against its parent's own
layers. What was wrong was the docstring, which claimed the parent's own
rows end the travel; it now describes the boundary as the wall and notes
that an empty folder is the one case that cannot cross layer rows,
matching the limit empty folders already have at the top level.
- Pin both behaviours with regression tests: a populated child steps over
its parent's own layers and then stops at an unrelated top-level group,
and an empty child reports no move when only layer rows are adjacent.
* Address Claude review feedback
- Add automated coverage at two levels of nesting, which the earlier tests
did not reach: a grandchild folder placed by its own sibling rather than
by either ancestor, the full ancestor-first header chain drawn against
one layer row, and a grandchild moving among its siblings with its own
parent (not the outer group) as the wall. branchUnder's ancestor walk
and the sibling-anchoring loop are the parts that could regress at depth
2 without a test noticing.1 parent 3108e4b commit c335783
3 files changed
Lines changed: 361 additions & 126 deletions
File tree
- apps/geolibre-desktop/src/components/panels
- packages/core/src
- tests
Lines changed: 13 additions & 64 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
920 | 920 | | |
921 | 921 | | |
922 | 922 | | |
923 | | - | |
924 | | - | |
925 | | - | |
926 | | - | |
927 | | - | |
928 | | - | |
929 | | - | |
930 | | - | |
931 | | - | |
932 | | - | |
933 | | - | |
934 | | - | |
935 | | - | |
936 | | - | |
937 | | - | |
938 | | - | |
939 | | - | |
940 | | - | |
941 | | - | |
942 | | - | |
943 | | - | |
944 | | - | |
945 | | - | |
946 | | - | |
947 | | - | |
948 | | - | |
949 | | - | |
950 | | - | |
951 | | - | |
952 | | - | |
953 | | - | |
954 | | - | |
955 | | - | |
956 | | - | |
957 | | - | |
958 | | - | |
959 | | - | |
960 | | - | |
961 | | - | |
962 | | - | |
963 | | - | |
964 | | - | |
965 | | - | |
966 | | - | |
967 | | - | |
968 | | - | |
969 | | - | |
970 | | - | |
971 | | - | |
972 | | - | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
973 | 931 | | |
974 | 932 | | |
975 | 933 | | |
| |||
2939 | 2897 | | |
2940 | 2898 | | |
2941 | 2899 | | |
2942 | | - | |
2943 | 2900 | | |
2944 | 2901 | | |
2945 | 2902 | | |
| |||
3102 | 3059 | | |
3103 | 3060 | | |
3104 | 3061 | | |
3105 | | - | |
3106 | | - | |
| 3062 | + | |
| 3063 | + | |
3107 | 3064 | | |
3108 | | - | |
3109 | | - | |
3110 | | - | |
3111 | | - | |
3112 | | - | |
3113 | | - | |
3114 | | - | |
3115 | | - | |
3116 | 3065 | | |
3117 | 3066 | | |
3118 | 3067 | | |
| |||
4016 | 3965 | | |
4017 | 3966 | | |
4018 | 3967 | | |
4019 | | - | |
| 3968 | + | |
4020 | 3969 | | |
4021 | | - | |
| 3970 | + | |
4022 | 3971 | | |
4023 | 3972 | | |
4024 | 3973 | | |
| |||
0 commit comments