Skip to content

Build your personal knowledge base with Trilium Notes

client/collections/board: fix the cards not being able to be moved to the inbox column via keyboard

Adorian Doran3f3b1e2e64a4
diff --git a/apps/client/src/widgets/collections/board/keyboard.spec.tsx b/apps/client/src/widgets/collections/board/keyboard.spec.tsx
index d1e75bc0ed..6b427c6a00 100644
--- a/apps/client/src/widgets/collections/board/keyboard.spec.tsx
+++ b/apps/client/src/widgets/collections/board/keyboard.spec.tsx
@@ -560,6 +560,20 @@ describe("Board keyboard", () => {
expect(focusedName(board)).toBe("First");
});
+ /** The inbox is named by the empty string, which is a column like any other to move to. */
+ it("sends a card into the inbox column beside it", async () => {
+ const board = await renderBoard(undefined, undefined, [], true);
+ const strip = vi.spyOn(attributes, "removeOwnedLabelByName").mockReturnValue(true);
+ // The inbox is seeded at the front, so the first card stands in the column after it.
+ focusCard(board, 1, 0);
+
+ press(board, "ArrowLeft", { ctrlKey: true });
+ await settleWrites();
+
+ expect(strip).toHaveBeenCalled();
+ expect(namesIn(board, 0)).toEqual([ "First" ]);
+ });
+
it("sends every picked-out card to the next column, and leaves them picked out", async () => {
const board = await renderBoard();
const write = vi.spyOn(attributes, "setLabel").mockResolvedValue(undefined);
diff --git a/apps/client/src/widgets/collections/board/keyboard.ts b/apps/client/src/widgets/collections/board/keyboard.ts
index e2bb3e0228..69f75fbcd1 100644
--- a/apps/client/src/widgets/collections/board/keyboard.ts
+++ b/apps/client/src/widgets/collections/board/keyboard.ts
@@ -340,7 +340,7 @@ export function useBoardKeyboard({
// on the board offers.
const neighbour = columns[spot.column + 1] ?? columns[spot.column - 1];
api.confirmAndRemoveColumn(columns[spot.column]).then((removed) => {
- if (removed && neighbour) {
+ if (removed && neighbour !== undefined) {
pendingFocus.current = { intent: { column: neighbour, part: "header" } };
}
});
@@ -580,8 +580,9 @@ function move(
const target = toEnd
? columns[key === "ArrowRight" ? columns.length - 1 : 0]
: columns[spot.column + (key === "ArrowRight" ? 1 : -1)];
- // Only the whole way can ask for the column a card already stands in.
- if (!target || target === column) return false;
+ // Only the whole way can ask for the column a card already stands in. The inbox column
+ // is the empty string, so a column that is not there is the undefined one.
+ if (target === undefined || target === column) return false;
// A selection standing in several columns is left alone: each card has a neighbour of its
// own, and sending them all to one column is not what the key means anywhere else.