Skip to content

Build your personal knowledge base with Trilium Notes

client/collections/board: update the move first/last item/column key shortcuts

Adorian Doran64c3b0dd9235
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 5b016df4f5..60813677ac 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -3386,10 +3386,10 @@
"rename": "Rename item or column",
"moving": "Moving",
"move_item": "Move item up / down",
- "move_across": "Move to the previous / next column",
- "move_to_edge": "Move to the first / last column",
"move_within": "Move to the top / bottom of the column",
- "move_column": "Move the column left / right"
+ "move_across": "Move to the previous / next column",
+ "move_column": "Move the column left / right",
+ "move_column_to_edge": "Move the column to the far left / right"
},
"status-alias": "Status"
},
diff --git a/apps/client/src/widgets/collections/board/index.spec.tsx b/apps/client/src/widgets/collections/board/index.spec.tsx
index d250b5282a..d5c5e15b09 100644
--- a/apps/client/src/widgets/collections/board/index.spec.tsx
+++ b/apps/client/src/widgets/collections/board/index.spec.tsx
@@ -320,12 +320,15 @@ describe("Board column rename", () => {
{ keys: [ "Space" ], labelKey: "board_view.hints.open_item" },
{ keys: [ "F2" ], labelKey: "board_view.hints.rename" },
{ keys: [ "Ctrl+Up", "Ctrl+Down" ], labelKey: "board_view.hints.move_item" },
+ { keys: [ "Ctrl+Home", "Ctrl+End" ], labelKey: "board_view.hints.move_within" },
{ keys: [ "Ctrl+Left", "Ctrl+Right" ], labelKey: "board_view.hints.move_across" },
- { keys: [ "Ctrl+Home", "Ctrl+End" ], labelKey: "board_view.hints.move_to_edge" },
- { keys: [ "Ctrl+PageUp", "Ctrl+PageDown" ], labelKey: "board_view.hints.move_within" },
{
keys: [ "Ctrl+Alt+Left", "Ctrl+Alt+Right" ],
labelKey: "board_view.hints.move_column"
+ },
+ {
+ keys: [ "Ctrl+Alt+Home", "Ctrl+Alt+End" ],
+ labelKey: "board_view.hints.move_column_to_edge"
}
]);
});
diff --git a/apps/client/src/widgets/collections/board/index.tsx b/apps/client/src/widgets/collections/board/index.tsx
index f694130991..35d227002c 100644
--- a/apps/client/src/widgets/collections/board/index.tsx
+++ b/apps/client/src/widgets/collections/board/index.tsx
@@ -135,12 +135,15 @@ const BOARD_HINTS: ShortcutHintDefinition = [
titleKey: "board_view.hints.moving",
hints: [
{ keys: [ "Ctrl+Up", "Ctrl+Down" ], labelKey: "board_view.hints.move_item" },
+ { keys: [ "Ctrl+Home", "Ctrl+End" ], labelKey: "board_view.hints.move_within" },
{ keys: [ "Ctrl+Left", "Ctrl+Right" ], labelKey: "board_view.hints.move_across" },
- { keys: [ "Ctrl+Home", "Ctrl+End" ], labelKey: "board_view.hints.move_to_edge" },
- { keys: [ "Ctrl+PageUp", "Ctrl+PageDown" ], labelKey: "board_view.hints.move_within" },
{
keys: [ "Ctrl+Alt+Left", "Ctrl+Alt+Right" ],
labelKey: "board_view.hints.move_column"
+ },
+ {
+ keys: [ "Ctrl+Alt+Home", "Ctrl+Alt+End" ],
+ labelKey: "board_view.hints.move_column_to_edge"
}
]
}
diff --git a/apps/client/src/widgets/collections/board/keyboard.spec.tsx b/apps/client/src/widgets/collections/board/keyboard.spec.tsx
index 1fa7a13073..2789927362 100644
--- a/apps/client/src/widgets/collections/board/keyboard.spec.tsx
+++ b/apps/client/src/widgets/collections/board/keyboard.spec.tsx
@@ -119,7 +119,7 @@ describe("Board keyboard", () => {
// Even at an edge it moves nothing from: the board owns the key while focused.
focusCard(board, 0, 0);
press(board, "ArrowLeft", { ctrlKey: true });
- press(board, "PageDown", { ctrlKey: true });
+ press(board, "End", { ctrlKey: true });
press(board, "ArrowRight", { ctrlKey: true, altKey: true });
press(board, " ");
@@ -335,29 +335,16 @@ describe("Board keyboard", () => {
expect(focusedName(board)).toBe("Done");
});
- it("carries a card the whole way with Ctrl and Home or End", async () => {
+ it("sends a card to either end of its column with Ctrl and Home or End", async () => {
const board = await renderBoard();
- focusCard(board, 1, 0);
- const moved = noteOf(board, "Second");
+ focusCard(board, 0, 1);
press(board, "Home", { ctrlKey: true });
- setStatus(moved, "To Do");
- await redraw();
- expect(columnOf(board, "Second")).toBe(0);
-
- press(board, "End", { ctrlKey: true });
- setStatus(moved, "Done");
- await redraw();
- expect(columnOf(board, "Second")).toBe(2);
- });
+ expect(branches.moveBeforeBranch).toHaveBeenCalled();
- it("does not move a card already in the column Home or End would send it to", async () => {
- const board = await renderBoard();
focusCard(board, 0, 0);
-
- press(board, "Home", { ctrlKey: true });
-
- expect(columnOf(board, "First")).toBe(0);
+ press(board, "End", { ctrlKey: true });
+ expect(branches.moveAfterBranch).toHaveBeenCalled();
});
it("does nothing at the edges it cannot move past", async () => {
@@ -365,7 +352,7 @@ describe("Board keyboard", () => {
focusCard(board, 0, 0);
press(board, "ArrowUp", { ctrlKey: true });
- press(board, "PageUp", { ctrlKey: true });
+ press(board, "Home", { ctrlKey: true });
press(board, "ArrowLeft", { ctrlKey: true });
focusButton(board, 1);
@@ -417,17 +404,17 @@ describe("Board keyboard", () => {
expect(focusedName(board)).toBe("To Do");
});
- it("sends a column to either end with the page keys", async () => {
+ it("sends a column to either end with Ctrl, Alt and Home or End", async () => {
const board = await renderBoard();
focusHeader(board, 1);
- press(board, "PageUp", { ctrlKey: true, altKey: true });
+ press(board, "Home", { ctrlKey: true, altKey: true });
await act(async () => { await flush(); });
expect(saved.at(-1)?.columns?.map(column => column.value))
.toEqual([ "Doing", "To Do", "Done" ]);
focusHeader(board, 0);
- press(board, "PageDown", { ctrlKey: true, altKey: true });
+ press(board, "End", { ctrlKey: true, altKey: true });
await act(async () => { await flush(); });
expect(saved.at(-1)?.columns?.map(column => column.value))
.toEqual([ "To Do", "Done", "Doing" ]);
diff --git a/apps/client/src/widgets/collections/board/keyboard.ts b/apps/client/src/widgets/collections/board/keyboard.ts
index 740c565643..5839ef20a1 100644
--- a/apps/client/src/widgets/collections/board/keyboard.ts
+++ b/apps/client/src/widgets/collections/board/keyboard.ts
@@ -7,13 +7,11 @@ import { ColumnMap } from "./data";
/** Plain, these walk the board. */
const NAVIGATION_KEYS = [ "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Home", "End" ];
-/** With Ctrl, these carry the focused card: a step, a column across, or all the way to an end. */
-const ITEM_MOVE_KEYS = [
- "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "PageUp", "PageDown", "Home", "End"
-];
+/** With Ctrl, these carry the focused card: a step, a column across, or to an end of its own. */
+const ITEM_MOVE_KEYS = [ "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Home", "End" ];
/** With Ctrl and Alt, these carry the column focus is in, from wherever inside it focus sits. */
-const COLUMN_MOVE_KEYS = [ "ArrowLeft", "ArrowRight", "PageUp", "PageDown" ];
+const COLUMN_MOVE_KEYS = [ "ArrowLeft", "ArrowRight", "Home", "End" ];
/**
* A place on the board that can hold focus.
@@ -277,12 +275,9 @@ function move(
const { noteId } = item.note;
const { branchId } = item.branch;
- if (key === "ArrowLeft" || key === "ArrowRight" || key === "Home" || key === "End") {
- // Home and End carry the card the whole way, the way they carry the cursor within a column.
- const target = key === "Home" ? columns[0]
- : key === "End" ? columns[columns.length - 1]
- : columns[spot.column + (key === "ArrowRight" ? 1 : -1)];
- if (!target || target === column) return false;
+ if (key === "ArrowLeft" || key === "ArrowRight") {
+ const target = columns[spot.column + (key === "ArrowRight" ? 1 : -1)];
+ if (!target) return false;
return { intent: { noteId }, done: api.moveToColumnEnd(noteId, branchId, target) };
}
@@ -291,8 +286,8 @@ function move(
// A card is placed before a position too, so moving one down means passing the one below it.
const to = key === "ArrowUp" && spot.item > 0 ? spot.item - 1
: key === "ArrowDown" && spot.item < last ? spot.item + 2
- : key === "PageUp" && spot.item > 0 ? 0
- : key === "PageDown" && spot.item < last ? items.length
+ : key === "Home" && spot.item > 0 ? 0
+ : key === "End" && spot.item < last ? items.length
: null;
if (to === null) return false;
@@ -320,8 +315,8 @@ function shiftColumn(
// A column is placed before a position, so passing one to the right means passing two.
const to = key === "ArrowRight" && spot.column < last ? spot.column + 2
: key === "ArrowLeft" && spot.column > 0 ? spot.column - 1
- : key === "PageDown" && spot.column < last ? columns.length
- : key === "PageUp" && spot.column > 0 ? 0
+ : key === "End" && spot.column < last ? columns.length
+ : key === "Home" && spot.column > 0 ? 0
: null;
if (to === null) return false;