Skip to content

Build your personal knowledge base with Trilium Notes

client/collections/board: fix an issue

Adorian Doran21b4f965e310
diff --git a/apps/client/src/widgets/collections/board/keyboard.spec.tsx b/apps/client/src/widgets/collections/board/keyboard.spec.tsx
index 63d852da14..d9e1441292 100644
--- a/apps/client/src/widgets/collections/board/keyboard.spec.tsx
+++ b/apps/client/src/widgets/collections/board/keyboard.spec.tsx
@@ -118,6 +118,12 @@ describe("Board keyboard", () => {
const board = await renderBoard();
const content = board.querySelector<HTMLElement>(".board-column-content");
if (!content) throw new Error("expected a scrollable column body");
+ const seen = vi.fn();
+ for (const card of board.querySelectorAll(".board-note")) {
+ Object.defineProperty(card, "scrollIntoView", {
+ value: seen, configurable: true, writable: true
+ });
+ }
Object.defineProperty(content, "scrollHeight", {
value: 640, configurable: true, writable: true
});
@@ -131,6 +137,8 @@ describe("Board keyboard", () => {
expect(focusedName(board)).toBe("Second");
expect(content.scrollTop).toBe(640);
+ // And still asked into view, which is what carries the board across to its column.
+ expect(seen).toHaveBeenCalledWith({ block: "nearest", inline: "nearest" });
});
it("crosses to the first card of the next column rather than to its header", async () => {
diff --git a/apps/client/src/widgets/collections/board/keyboard.ts b/apps/client/src/widgets/collections/board/keyboard.ts
index ba38fa4c92..d1dfe55310 100644
--- a/apps/client/src/widgets/collections/board/keyboard.ts
+++ b/apps/client/src/widgets/collections/board/keyboard.ts
@@ -501,9 +501,12 @@ function reveal(element: HTMLElement) {
const content = element.closest<HTMLElement>(".board-column-content");
if (content && !element.nextElementSibling) {
content.scrollTop = content.scrollHeight;
- } else {
- element.scrollIntoView({ block: "nearest", inline: "nearest" });
}
+
+ // And into view either way, which is what carries the board sideways to the column a card
+ // has just crossed into. Asked for second, so a column already taken to its end is left
+ // where it stands.
+ element.scrollIntoView({ block: "nearest", inline: "nearest" });
}, FLIP_SETTLE_MS);
}