Skip to content

Build your personal knowledge base with Trilium Notes

client/collections/board: fix some issues

Adorian Doranabe65e074333
diff --git a/apps/client/src/widgets/collections/board/board_drag.spec.tsx b/apps/client/src/widgets/collections/board/board_drag.spec.tsx
index b85894e94b..9b9c63c1a6 100644
--- a/apps/client/src/widgets/collections/board/board_drag.spec.tsx
+++ b/apps/client/src/widgets/collections/board/board_drag.spec.tsx
@@ -326,6 +326,31 @@ describe("useBoardDrag, carrying a card", () => {
expect(menus).toEqual([ "heading" ]);
});
+ /**
+ * A finger has no second button, so a tap is what asks for a menu. The strip is the one place
+ * where a tap already means something else: it opens the column, its menu being on the button
+ * the strip carries.
+ */
+ it("leaves a tap on a collapsed column to open it", () => {
+ setup();
+ const heading = board.querySelector<HTMLElement>(".board-column h3");
+ const column = heading?.closest<HTMLElement>(".board-column");
+ if (!heading || !column) throw new Error("expected a heading");
+ column.classList.add("collapsed");
+
+ const menus: string[] = [];
+ const clicks: string[] = [];
+ heading.addEventListener("contextmenu", () => menus.push("heading"));
+ board.addEventListener("click", () => clicks.push("click"));
+
+ press(heading, 10, 10, "touch");
+ release(11, 11, "touch");
+ heading.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+
+ expect(menus).toEqual([]);
+ expect(clicks).toEqual([ "click" ]);
+ });
+
it("leaves the click a tap also lands unanswered", () => {
setup();
const element = card("n1");
diff --git a/apps/client/src/widgets/collections/board/board_drag.ts b/apps/client/src/widgets/collections/board/board_drag.ts
index f9c61b3333..d70ce2d832 100644
--- a/apps/client/src/widgets/collections/board/board_drag.ts
+++ b/apps/client/src/widgets/collections/board/board_drag.ts
@@ -333,10 +333,14 @@ export function useBoardDrag(
&& Math.hypot(event.clientX - held.startX, event.clientY - held.startY)
<= TOUCH_TOLERANCE;
const target = held.menuTarget;
+ // A tap on a collapsed column opens it: that is what the strip is for, and its menu is
+ // on the button it carries. Everything else answers a tap with its menu, the long
+ // press that would otherwise open one being how a finger picks something up.
+ const opens = target.closest(".board-column")?.classList.contains("collapsed");
close(event.type === "pointercancel");
- if (tapped) {
+ if (tapped && !opens) {
// The browser follows a tap with mouse events for pages that know nothing of touch,
// and they land on the menu this is about to open, right under the finger: the
// first of them takes the menu straight back off again. Refused at `touchend`,
diff --git a/apps/client/src/widgets/collections/board/index.css b/apps/client/src/widgets/collections/board/index.css
index ae65ccb098..bd9a06cce3 100644
--- a/apps/client/src/widgets/collections/board/index.css
+++ b/apps/client/src/widgets/collections/board/index.css
@@ -718,7 +718,12 @@ body.mobile .column-drop-placeholder {
.board-view-container .board-column.collapsed {
width: var(--board-collapsed-column-width);
overflow: hidden;
- /* Width and not a transform: the columns beside it have to move with it. */
+}
+
+/* Width and not a transform: the columns beside it have to move with it. The copy being carried is
+ left out, or it would ease towards each frame's position instead of taking it: its `transition:
+ none` above carries no more weight than this rule and stands above it in the file. */
+.board-view-container .board-column.collapsed:not(.board-drag-preview) {
transition: border-color 0.2s ease, transform 0.2s ease,
width var(--board-collapse-duration) ease;
}
@@ -730,7 +735,8 @@ body.mobile .column-drop-placeholder {
}
@media (prefers-reduced-motion: reduce) {
- .board-view-container .board-column.collapsed {
+ /* Matching the selector above, which it has to outweigh rather than merely follow. */
+ .board-view-container .board-column.collapsed:not(.board-drag-preview) {
transition: border-color 0.2s ease;
}
}