Commit de53fe9
fix(kanban): disable card drag-reorder while a filter is active
Context:
In board view, item drag-drop computes the drop index by scanning the rendered
[data-item-id] cards (handleItemDrop), then passes that index to moveItem, which
splices into the lane's full, stored items array. Dragging was already disabled
for non-manual sort modes via disableDrag={!isManualSort}, because a sorted view
reorders the cards relative to storage.
Problem:
A text filter (filterItems) also makes the rendered cards a subset of the lane's
items, but drag stayed enabled in manual sort mode. With a filter active, the
drop index (a position among the visible/filtered cards) was spliced into the
unfiltered array, so the dragged card landed at the wrong position. applyChange
then serialized and persisted the corrupted order to the .kanban file. The
cross-lane drop path was affected identically.
Solution:
- Add a pure `canReorderItems(sortMode, filterQuery)` helper: reorder is valid
only when sort is manual AND no filter is active (rendered order == stored
order).
- Wire it in KanbanView as `disableDrag={!canReorder}`. KanbanCard already maps
disableDrag to draggable=false and drops the dragstart handler, so no drag
begins and handleItemDrop's `if (!dragItemId) return` guard short-circuits.
Behavior:
- Manual sort + no filter: drag-reorder works (unchanged).
- Manual sort + active filter: cards are no longer draggable (no silent
misplacement / file corruption).
- Non-manual sort: drag stays disabled (unchanged).
Files:
- src/lib/plugins/kanban/kanban.logic.ts:688-700 — `canReorderItems` helper.
- src/lib/plugins/kanban/KanbanView.svelte:43,162-165,525 — import, `canReorder`
derived, `disableDrag={!canReorder}`.
- src/tests/lib/plugins/kanban/kanban.logic.test.ts — canReorderItems cases
(manual/no-filter true; filtered false; sorted false).
- tasks/todo/bug-hunt-fixes.md — H6 marked done.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 2e0cd92 commit de53fe9
4 files changed
Lines changed: 42 additions & 2 deletions
File tree
- src
- lib/plugins/kanban
- tests/lib/plugins/kanban
- tasks/todo
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
| |||
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
162 | 167 | | |
163 | 168 | | |
164 | 169 | | |
| |||
519 | 524 | | |
520 | 525 | | |
521 | 526 | | |
522 | | - | |
| 527 | + | |
523 | 528 | | |
524 | 529 | | |
525 | 530 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
685 | 685 | | |
686 | 686 | | |
687 | 687 | | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
688 | 702 | | |
689 | 703 | | |
690 | 704 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| |||
1519 | 1520 | | |
1520 | 1521 | | |
1521 | 1522 | | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
0 commit comments