Skip to content

Build your personal knowledge base with Trilium Notes

client/collections/board: fix some issues

Adorian Doran63ab173ebc44
diff --git a/apps/client/src/services/dialog.ts b/apps/client/src/services/dialog.ts
index f1cf23f3d4..4bf85badef 100644
--- a/apps/client/src/services/dialog.ts
+++ b/apps/client/src/services/dialog.ts
@@ -212,7 +212,7 @@ async function confirm(message: MessageType) {
/**
* Asks a yes/no question that also offers to delete the notes it is about.
*
- * The offer is worded by the caller, and left out entirely where `checkboxLabel` is absent.
+ * The caller words the offer. Pass no `checkboxLabel` to ask the question alone.
*
* @returns the answer and whether the box was ticked, or `false` where the reader backed out.
*/
diff --git a/apps/client/src/widgets/collections/board/api.spec.ts b/apps/client/src/widgets/collections/board/api.spec.ts
index 450d9529ca..02cd5e0390 100644
--- a/apps/client/src/widgets/collections/board/api.spec.ts
+++ b/apps/client/src/widgets/collections/board/api.spec.ts
@@ -1540,7 +1540,7 @@ describe("removing a column with the question put first", () => {
const error = vi.spyOn(toast, "showError").mockReturnValue(undefined);
expect(await api.confirmAndRemoveColumn("Done")).toBe(false);
- // An empty column has no notes to offer, so the box is left out.
+ // The box is about notes to delete, and an empty column has none.
expect(confirm).toHaveBeenCalledWith("board_view.delete-column-confirmation", undefined);
expect(saved).toEqual([]);
@@ -1556,8 +1556,8 @@ describe("removing a column with the question put first", () => {
});
/**
- * The column's own cards are what the offer covers, so taking it deletes the notes instead of
- * stripping the grouping value and leaving them on the board.
+ * Taking the offer deletes the column's cards, rather than stripping the grouping value and
+ * leaving them on the board.
*/
it("deletes the notes in the column when the offer is taken", async () => {
const { api, saved } = createApi(
@@ -2049,8 +2049,8 @@ describe("filing a card under the inbox", () => {
describe("the limit set on a column", () => {
/**
- * The inbox is where every card without a grouping value goes, so a limit there is not
- * enforceable. One stored by an older board is read as none.
+ * The inbox takes every card without a grouping value, however many that is. A limit stored
+ * for it by an older board is read as none.
*/
it("reads no limit for the inbox and writes none to it", async () => {
const { api, saved } = createApi(
diff --git a/apps/client/src/widgets/collections/board/api.ts b/apps/client/src/widgets/collections/board/api.ts
index dda4c5f5fb..55328a2fdd 100644
--- a/apps/client/src/widgets/collections/board/api.ts
+++ b/apps/client/src/widgets/collections/board/api.ts
@@ -506,8 +506,8 @@ export default class BoardApi {
* @returns whether the column went, for a caller with something to do afterwards.
*/
async confirmAndRemoveColumn(column: string) {
- // Counted off the map `removeColumn` acts on, so a filter hiding part of the column does
- // not make the offer read as covering fewer notes than it takes.
+ // `removeColumn` acts on this map too, so a filter hiding part of the column cannot make
+ // the offer undercount.
const cards = (this.allByColumn ?? this.byColumn)?.get(column)?.length ?? 0;
const answer = await dialog.confirmWithNoteDeletion(
t("board_view.delete-column-confirmation"),
@@ -533,8 +533,7 @@ export default class BoardApi {
* grouping value taken off them.
*/
async removeColumn(column: string, deleteNotes = false) {
- // Read off the unfiltered map where there is one, so the cards an active filter is not
- // showing are covered too.
+ // `allByColumn` covers the cards an active filter is not showing.
const items = (this.allByColumn ?? this.byColumn)?.get(column);
const noteIds = items?.map(item => item.note.noteId) || [];
diff --git a/apps/client/src/widgets/collections/board/column.tsx b/apps/client/src/widgets/collections/board/column.tsx
index b6c0f6fc01..026143956e 100644
--- a/apps/client/src/widgets/collections/board/column.tsx
+++ b/apps/client/src/widgets/collections/board/column.tsx
@@ -526,8 +526,8 @@ export default function Column({
collapse();
}
- // Enter makes a card at the head of the column, Shift+Enter one at its foot. Ctrl+Enter
- // inserts a column and is left to `keyboard.ts`, which also opens a collapsed column.
+ // Enter makes a card at the head of the column, Shift+Enter one at its foot.
+ // `keyboard.ts` takes Ctrl+Enter for a column, and Enter on a strip.
if (e.key === "Enter" && !e.ctrlKey && !isCollapsed && e.target === e.currentTarget) {
e.preventDefault();
e.stopPropagation();
diff --git a/apps/client/src/widgets/collections/board/context_menu.spec.ts b/apps/client/src/widgets/collections/board/context_menu.spec.ts
index 6f12b9fa8d..16ac8c4b19 100644
--- a/apps/client/src/widgets/collections/board/context_menu.spec.ts
+++ b/apps/client/src/widgets/collections/board/context_menu.spec.ts
@@ -219,8 +219,7 @@ describe("Board column context menu", () => {
expect(icons).not.toContain("bx bx-archive");
// The inbox leads the board and cannot be moved off the head of it.
expect(icons).not.toContain("bx bx-horizontal-left");
- // The inbox is where every card without a grouping value goes, so a limit there is not
- // enforceable.
+ // The inbox takes every card without a grouping value, however many that is.
expect(icons).not.toContain("bx bx-tachometer");
const remove = items.find(item =>
diff --git a/apps/client/src/widgets/collections/board/context_menu.ts b/apps/client/src/widgets/collections/board/context_menu.ts
index fc694fdfff..94ccf59829 100644
--- a/apps/client/src/widgets/collections/board/context_menu.ts
+++ b/apps/client/src/widgets/collections/board/context_menu.ts
@@ -144,8 +144,6 @@ export function openColumnContextMenu(api: Api, event: ContextMenuEvent, column:
uiIcon: "bx bx-sort-alt-2",
items: buildSortMenuItems<string>(sortMenuOptions(api, column.value))
},
- // The inbox is where every card without a grouping value goes, so a limit there is
- // not enforceable.
...(isInbox ? [] : [ {
title: t("board_view.set-limit"),
uiIcon: "bx bx-tachometer",
diff --git a/apps/client/src/widgets/collections/board/index.spec.tsx b/apps/client/src/widgets/collections/board/index.spec.tsx
index 0a3f19644d..fb322392d3 100644
--- a/apps/client/src/widgets/collections/board/index.spec.tsx
+++ b/apps/client/src/widgets/collections/board/index.spec.tsx
@@ -2074,8 +2074,8 @@ describe("Board column rename", () => {
});
/**
- * A heading holds no card to insert beside, so the ends of the column are what Enter and
- * Shift+Enter reach there.
+ * A heading has no card to insert beside, so Enter and Shift+Enter reach the ends of the
+ * column instead.
*/
it("opens the field at the head of the column for Enter on its heading", async () => {
const { container } = await setup();
@@ -2106,7 +2106,7 @@ describe("Board column rename", () => {
await flush();
});
- // The footer's own field, which stands outside the cards rather than among them.
+ // The footer's own field, drawn outside the cards rather than among them.
expect(column.querySelector(".board-column-content .board-new-item")).toBeNull();
expect(column.querySelector(".board-new-item.editing")).toBeTruthy();
});
diff --git a/apps/client/src/widgets/collections/board/keyboard.spec.tsx b/apps/client/src/widgets/collections/board/keyboard.spec.tsx
index 6b427c6a00..15b12ff8f8 100644
--- a/apps/client/src/widgets/collections/board/keyboard.spec.tsx
+++ b/apps/client/src/widgets/collections/board/keyboard.spec.tsx
@@ -564,7 +564,7 @@ describe("Board keyboard", () => {
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.
+ // The inbox is seeded at the front, so the first card is in the column after it.
focusCard(board, 1, 0);
press(board, "ArrowLeft", { ctrlKey: true });
diff --git a/apps/client/src/widgets/collections/board/keyboard.ts b/apps/client/src/widgets/collections/board/keyboard.ts
index 0068f0780f..705d4af153 100644
--- a/apps/client/src/widgets/collections/board/keyboard.ts
+++ b/apps/client/src/widgets/collections/board/keyboard.ts
@@ -336,8 +336,7 @@ export function useBoardKeyboard({
take(e);
// Where focus goes once the column is gone, taken up only if it does go. Shift is
- // left unanswered here: the confirmation is where the notes in the column are asked
- // about, so there is nothing for a modifier to say.
+ // left unanswered here: the confirmation asks about the notes in the column.
const neighbour = columns[spot.column + 1] ?? columns[spot.column - 1];
api.confirmAndRemoveColumn(columns[spot.column]).then((removed) => {
if (removed && neighbour !== undefined) {
@@ -580,8 +579,7 @@ 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. The inbox column
- // is the empty string, so a column that is not there is the undefined one.
+ // Only the whole way can ask for the column a card already stands in.
if (target === undefined || target === column) return false;
// A selection standing in several columns is left alone: each card has a neighbour of its
diff --git a/apps/client/src/widgets/dialogs/confirm.spec.tsx b/apps/client/src/widgets/dialogs/confirm.spec.tsx
index 8ba53bbac5..c2603f1ce7 100644
--- a/apps/client/src/widgets/dialogs/confirm.spec.tsx
+++ b/apps/client/src/widgets/dialogs/confirm.spec.tsx
@@ -141,9 +141,8 @@ describe("ConfirmDialog", () => {
});
/**
- * A caller removing something of its own — a board column, say — offers to delete the notes
- * that go with it in its own words. The verdict the note box carries is not shown, the notes
- * being the caller's to count rather than this dialog's to look up.
+ * A caller removing something of its own, a board column say, words the offer itself. It
+ * counts the notes too, so the dialog adds no verdict line of its own.
*/
it("offers the caller's own box, and answers with what was done to it", async () => {
const answers: { confirmed: boolean, isDeleteNoteChecked: boolean }[] = [];
diff --git a/apps/client/src/widgets/dialogs/confirm.tsx b/apps/client/src/widgets/dialogs/confirm.tsx
index 954bf59c16..410a081936 100644
--- a/apps/client/src/widgets/dialogs/confirm.tsx
+++ b/apps/client/src/widgets/dialogs/confirm.tsx
@@ -138,8 +138,8 @@ export interface ConfirmWithMessageOptions {
message: MessageType;
callback: ConfirmDialogCallback;
/**
- * Wording for a checkbox offering to delete the notes the question is about, left out where
- * there is nothing to offer. Its state comes back as `isDeleteNoteChecked`.
+ * Wording for a checkbox offering to delete the notes the question is about. Omit it to ask
+ * the question alone. The tick comes back as `isDeleteNoteChecked`.
*/
checkboxLabel?: string;
}