Skip to content

Build your personal knowledge base with Trilium Notes

client/collections/board: limit the width of column names in the column context menu

Adorian Doranc4605c32f541
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 b4476d77a9..5b010060d7 100644
--- a/apps/client/src/widgets/collections/board/context_menu.spec.ts
+++ b/apps/client/src/widgets/collections/board/context_menu.spec.ts
@@ -151,6 +151,31 @@ describe("Board column context menu", () => {
expect(places(2)).toEqual([ 0, 1 ]);
});
+ it("boxes the column names it offers to move past, as the status list does", () => {
+ const api = {
+ getColumnIcon: () => DEFAULT_COLUMN_ICON,
+ getColumnColorClass: () => "",
+ isColumnArchived: () => false
+ } as unknown as BoardApi;
+
+ const menu = openMenu(api, { columns: [ "To Do", "Doing", "Done" ], index: 2 });
+ const entry = menu.find(item =>
+ item && "uiIcon" in item && item.uiIcon === "bx bx-horizontal-left");
+ if (!entry || !("items" in entry)) throw new Error("expected a move-column entry");
+
+ // The head of the board carries no name, so only the ones naming a column are boxed.
+ const after = (entry.items ?? []).slice(1);
+ expect(after).toHaveLength(1);
+
+ // i18next is never initialised under test, so what it interpolates comes back undefined;
+ // the box around it is what this is about.
+ for (const item of after) {
+ expect(item && "title" in item ? item.title : "")
+ .toMatch(/^<span class="board-column-name">.*<\/span>$/);
+ expect(item).toMatchObject({ className: "board-column-item" });
+ }
+ });
+
it("offers both sides to put a new column on", () => {
const onAddColumn = vi.fn();
const parent = openMenu({} as BoardApi, {}, { onAddColumn })
diff --git a/apps/client/src/widgets/collections/board/context_menu.ts b/apps/client/src/widgets/collections/board/context_menu.ts
index fe73fde011..7896292d94 100644
--- a/apps/client/src/widgets/collections/board/context_menu.ts
+++ b/apps/client/src/widgets/collections/board/context_menu.ts
@@ -137,7 +137,11 @@ function buildMoveColumnItems(api: Api, column: ColumnMenuTarget): MenuItem<stri
}
return [ {
- title: t("board_view.move-column-after", { column: name }),
+ // Boxed the way the status list boxes its names, so a long one is cut rather than
+ // widening the menu. What `t()` interpolates it has already escaped.
+ title: `<span class="board-column-name">`
+ + `${t("board_view.move-column-after", { column: name })}</span>`,
+ className: "board-column-item",
uiIcon: api.getColumnIcon(name),
iconColorClass: api.getColumnColorClass(name),
badges: api.isColumnArchived(name)