Skip to content

Build your personal knowledge base with Trilium Notes

client/collections/board: fix some issues

Adorian Dorane70cc1104de9
diff --git a/apps/client/src/widgets/collections/board/column.tsx b/apps/client/src/widgets/collections/board/column.tsx
index a5d9a5ee86..3854860aa2 100644
--- a/apps/client/src/widgets/collections/board/column.tsx
+++ b/apps/client/src/widgets/collections/board/column.tsx
@@ -27,16 +27,13 @@ import { useScrollFade } from "../../react/scroll_fade";
*/
const FOOTER_QUIET_MS = 5000;
-/** What a card is drawn with until an icon is picked for it, which is what a text note carries. */
-const DEFAULT_CARD_ICON = "bx bx-note";
-
/** How long an open takes. Matches `--board-expand-duration` in the board's own rules. */
const EXPAND_MS = 200;
import NoteLink from "../../react/NoteLink";
import { BoardActionsContext, BoardDragStateContext, TitleEditor } from ".";
import BoardApi from "./api";
import Card from "./card";
-import { DEFAULT_COLUMN_ICON, INBOX_COLUMN } from "./columns";
+import { DEFAULT_CARD_ICON, DEFAULT_COLUMN_ICON, INBOX_COLUMN } from "./columns";
import { openColumnContextMenu, openCreateCardMenu } from "./context_menu";
interface DragContext {
diff --git a/apps/client/src/widgets/collections/board/columns.ts b/apps/client/src/widgets/collections/board/columns.ts
index 57c72a0315..fccfdc92ef 100644
--- a/apps/client/src/widgets/collections/board/columns.ts
+++ b/apps/client/src/widgets/collections/board/columns.ts
@@ -17,6 +17,9 @@ export const DEFAULT_GROUP_BY = "status";
/** The icon a column shows until one is picked for it. */
export const DEFAULT_COLUMN_ICON = "bx bx-circle";
+/** What a card is drawn with until an icon is picked for it, which is what a text note carries. */
+export const DEFAULT_CARD_ICON = "bx bx-note";
+
/**
* The value identifying the inbox column: the empty string, which is what a card with no
* grouping value has.
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 f954748eb3..f671b1ca33 100644
--- a/apps/client/src/widgets/collections/board/context_menu.spec.ts
+++ b/apps/client/src/widgets/collections/board/context_menu.spec.ts
@@ -523,32 +523,37 @@ describe("Board item context menu", () => {
} as unknown as BoardApi;
const listed = statusItems(api, "One");
- expect(names(listed.slice(0, -1))).toEqual(columns.slice(0, 7));
+ expect(names(listed.slice(0, -1))).toEqual(columns.slice(0, 7).map(boxed));
// Named by its icon: `t()` answers with nothing here, i18next never being initialised.
const more = listed.at(-1);
if (!more || !("items" in more) || !more.items) throw new Error("expected a more entry");
expect("uiIcon" in more && more.uiIcon).toBe("bx bx-dots-horizontal-rounded");
- expect(names(more.items)).toEqual([ "Eight", "Nine" ]);
+ expect(names(more.items)).toEqual([ "Eight", "Nine" ].map(boxed));
// The card is in the ninth column, which stands in the menu itself along with the first
// seven, and is gone from what the entry holds.
const withNinth = statusItems(api, "Nine");
- expect(names(withNinth.slice(0, -1))).toEqual([ ...columns.slice(0, 7), "Nine" ]);
+ expect(names(withNinth.slice(0, -1)))
+ .toEqual([ ...columns.slice(0, 7), "Nine" ].map(boxed));
const rest = withNinth.at(-1);
if (!rest || !("items" in rest) || !rest.items) throw new Error("expected a more entry");
- expect(names(rest.items)).toEqual([ "Eight" ]);
+ expect(names(rest.items)).toEqual([ "Eight" ].map(boxed));
// Seven of them fit as they are.
expect(names(statusItems({ ...api, columns: columns.slice(0, 7) } as BoardApi, "One")))
- .toEqual(columns.slice(0, 7));
+ .toEqual(columns.slice(0, 7).map(boxed));
});
- /** The names the menu shows, each boxed in a span the stylesheet sizes. */
+ /** The titles the menu shows, each name boxed in the span the stylesheet sizes. */
function names(items: MenuItem<unknown>[]) {
- return items.flatMap(item => item && "title" in item && item.title
- ? [ item.title.replace(/<[^>]*>/g, "") ]
- : []);
+ return items.flatMap(item =>
+ item && "title" in item && item.title ? [ item.title ] : []);
+ }
+
+ /** A name as the menu writes it, which is what `names` reads back. */
+ function boxed(name: string) {
+ return `<span class="board-column-name">${name}</span>`;
}
/** Opens the menu a card offers, and hands back what it was given to show. */