Skip to content

Build your personal knowledge base with Trilium Notes

client/collections/board: fix an issue

Adorian Doran18921f8831e6
diff --git a/apps/client/src/widgets/collections/board/board_drag.ts b/apps/client/src/widgets/collections/board/board_drag.ts
index 84214245e2..f9c61b3333 100644
--- a/apps/client/src/widgets/collections/board/board_drag.ts
+++ b/apps/client/src/widgets/collections/board/board_drag.ts
@@ -425,13 +425,14 @@ export function useBoardDrag(
}
const measurement = measureBoard(container);
- // Each column keeps the cards it was measured with. The board now holds the gap where the
- // card was, which stands every card below it one place lower, so reading them again would
- // take the drag's own doing for a move of its own and the places would creep away from the
- // card with every one it passes.
+ // A column that was measured with cards keeps them. The board now holds the gap where the
+ // carried card was, which stands every card below it one place lower, so reading them again
+ // would take the drag's own doing for a move of its own and the places would creep away
+ // from the card with every one it passes. A column measured with none is read afresh: a
+ // collapsed one draws no cards at all until it opens, which is what this runs for.
for (const column of measurement.columns) {
const before = held.measurement?.columns.find(({ value }) => value === column.value);
- if (before) {
+ if (before?.cards.length) {
column.cards = before.cards;
}
}
diff --git a/apps/client/src/widgets/collections/board/drag_measure.ts b/apps/client/src/widgets/collections/board/drag_measure.ts
index 93fb87b37c..1bc14ea5dc 100644
--- a/apps/client/src/widgets/collections/board/drag_measure.ts
+++ b/apps/client/src/widgets/collections/board/drag_measure.ts
@@ -1,4 +1,4 @@
-import { type ColumnBox } from "./drag_geometry";
+import { type CardBox, type ColumnBox } from "./drag_geometry";
/** What a drag measures once at its start, and reads for the rest of the gesture. */
export interface BoardMeasurement {
@@ -70,9 +70,24 @@ function measureCards(area: HTMLElement | null) {
}
const top = area.getBoundingClientRect().top - area.scrollTop;
+ const cards: CardBox[] = [];
+ // The gap standing open for the carried card holds the cards under it a place lower than they
+ // are measured to be. What a place is counted against is the column without the drag's own
+ // doing in it, so the room the gap takes is given back to everything below it.
+ let gap = 0;
- return [ ...area.querySelectorAll<HTMLElement>(".board-note") ].map((card) => {
- const rect = card.getBoundingClientRect();
- return { top: rect.top - top, height: rect.height };
- });
+ for (const child of area.children) {
+ const rect = child.getBoundingClientRect();
+
+ if (child.classList.contains("board-drop-placeholder")) {
+ gap += rect.height + Number.parseFloat(getComputedStyle(child).marginBottom || "0");
+ continue;
+ }
+
+ if (child.classList.contains("board-note")) {
+ cards.push({ top: rect.top - top - gap, height: rect.height });
+ }
+ }
+
+ return cards;
}