Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/collections/board: tweak the column layout while being dragged
Adorian Doran23a6fe89ee57
diff --git a/apps/client/src/widgets/collections/board/board_drag.spec.tsx b/apps/client/src/widgets/collections/board/board_drag.spec.tsxindex f6069aa649..2303a11998 100644--- a/apps/client/src/widgets/collections/board/board_drag.spec.tsx+++ b/apps/client/src/widgets/collections/board/board_drag.spec.tsx@@ -502,7 +502,8 @@ describe("useBoardDrag, carrying a card", () => {move(120, 10);const copy = board.querySelector<HTMLElement>(".board-column.board-drag-preview");- expect(copy?.style.height).toBe("150px");+ expect(copy?.style.maxHeight).toBe("150px");+ expect(copy?.style.height).toBe("");expect(copy?.style.width).toBe("100px");expect(column?.style.display).toBe("none");});diff --git a/apps/client/src/widgets/collections/board/board_drag.ts b/apps/client/src/widgets/collections/board/board_drag.tsindex 54a927e2a6..b0bf5e69ed 100644--- a/apps/client/src/widgets/collections/board/board_drag.ts+++ b/apps/client/src/widgets/collections/board/board_drag.ts@@ -18,8 +18,8 @@ const TOUCH_TOLERANCE = 8;/** How much a carried card shrinks. Written with the movement, a class could not add to it. */const DRAG_SCALE = 0.9;-/** How tall a carried column stands, whatever it holds, so it can be seen past. */-const COLUMN_DRAG_HEIGHT = 150;+/** How tall a carried column is allowed to stand, so a full one can be seen past. */+const COLUMN_DRAG_MAX_HEIGHT = 150;/** How long a card rests on a column's heading before it counts as standing there. */const DWELL_MS = 500;@@ -477,8 +477,9 @@ function startColumn(target: HTMLElement, container: HTMLElement): ColumnSubject* Takes a copy of what is being carried out of the board's flow and hands it back.** The copy is positioned against the window, which no ancestor's overflow can clip, and stands- * inside the board so that the board's own styling still reaches it. A column is cut to a set- * height, so that a tall one does not cover the board it is being placed on.+ * inside the board so that the board's own styling still reaches it. A column is capped rather than+ * given a height, so that a tall one does not cover the board it is being placed on while a short+ * one still stands as tall as it is.*/function lift(held: Gesture, container: HTMLElement) {const rect = held.element.getBoundingClientRect();@@ -490,12 +491,15 @@ function lift(held: Gesture, container: HTMLElement) {// A copy can be used for nothing, and the copy stands outside the column its controls are// styled from, so what it offers is taken out rather than left showing.preview.querySelector(".edit-icon")?.remove();+ preview.querySelector(".board-new-item")?.remove();for (const [ property, value ] of Object.entries({left: `${rect.left}px`,top: `${rect.top}px`,width: `${rect.width}px`,- height: held.kind === "column" ? `${COLUMN_DRAG_HEIGHT}px` : `${rect.height}px`+ ...(held.kind === "column"+ ? { "max-height": `${COLUMN_DRAG_MAX_HEIGHT}px` }+ : { height: `${rect.height}px` })})) {preview.style.setProperty(property, value);}diff --git a/apps/client/src/widgets/collections/board/drag.spec.tsx b/apps/client/src/widgets/collections/board/drag.spec.tsxindex 2e7c9eb85e..50224afc4d 100644--- a/apps/client/src/widgets/collections/board/drag.spec.tsx+++ b/apps/client/src/widgets/collections/board/drag.spec.tsx@@ -467,14 +467,17 @@ describe("Board column reordering", () => {expect(placeholder?.style.width).toBe("");});- /** A copy of it is carried, cut to a set height so a tall column does not cover the board. */+ /** A copy of it is carried, capped so a tall column does not cover the board it is placed on. */it("carries a copy, hiding the column until it is let go", async () => {const { columns, board } = await renderColumns();await carryColumn(columns[0], 280, { release: false });const copy = board.querySelector<HTMLElement>(".board-column.board-drag-preview");expect(copy).toBeTruthy();- expect(copy?.style.height).toBe("150px");+ expect(copy?.style.maxHeight).toBe("150px");+ expect(copy?.style.height).toBe("");+ // Nothing on the copy can be used, and the footer would stand under cards it cannot add to.+ expect(copy?.querySelector(".board-new-item")).toBeNull();expect(columns[0].style.display).toBe("none");await columnPointer(board, "pointerup", 280);