Skip to content

Build your personal knowledge base with Trilium Notes

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

Adorian Doran8df93050f70c
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 4055be0e32..b4476d77a9 100644
--- a/apps/client/src/widgets/collections/board/context_menu.spec.ts
+++ b/apps/client/src/widgets/collections/board/context_menu.spec.ts
@@ -364,14 +364,17 @@ describe("Board item context menu", () => {
const columns = statusItems(api);
- expect(columns.map(item => item && "title" in item ? item.title : undefined))
- .toEqual([ "To Do", "Done" ]);
+ // Each name sits in a box of its own, which is what the stylesheet sizes.
+ expect(columns.map(item => item && "title" in item ? item.title : undefined)).toEqual([
+ '<span class="board-column-name">To Do</span>',
+ '<span class="board-column-name">Done</span>'
+ ]);
// The tick goes at the trailing edge, leaving each column's own icon where it stands.
expect(columns.map(item => item && "trailingIcon" in item ? item.trailingIcon : undefined))
.toEqual([ "bx bx-check", undefined ]);
// And carries the class the stylesheet weights it by.
expect(columns.map(item => item && "className" in item ? item.className : undefined))
- .toEqual([ "board-current-column", undefined ]);
+ .toEqual([ "board-column-item board-current-column", "board-column-item" ]);
const done = columns[1];
if (done && "handler" in done) done.handler?.(done, {} as never);
@@ -410,9 +413,25 @@ describe("Board item context menu", () => {
} as unknown as BoardApi;
const [ column ] = statusItems(api);
+ const title = column && "title" in column ? column.title : "";
- expect(column && "title" in column ? column.title : undefined)
- .toBe("Done &lt;button id&#x3D;&quot;planted&quot;&gt;press&lt;&#x2F;button&gt;");
+ // The name sits in a box of its own, which is what the width is set on, and nothing of the
+ // name itself is left as markup.
+ expect(title).toBe('<span class="board-column-name">'
+ + "Done &lt;button id&#x3D;&quot;planted&quot;&gt;press&lt;&#x2F;button&gt;</span>");
+ });
+
+ it("names every column entry for the stylesheet to size", () => {
+ const api = {
+ columns: [ "To Do", "Done" ],
+ isColumnArchived: () => false,
+ getColumnIcon: () => DEFAULT_COLUMN_ICON,
+ getColumnColorClass: () => ""
+ } as unknown as BoardApi;
+
+ expect(statusItems(api)
+ .map(item => item && "className" in item ? item.className : undefined))
+ .toEqual([ "board-column-item board-current-column", "board-column-item" ]);
});
it("shows each column with the icon and colour it carries", () => {
diff --git a/apps/client/src/widgets/collections/board/context_menu.ts b/apps/client/src/widgets/collections/board/context_menu.ts
index 346ca371a8..fe73fde011 100644
--- a/apps/client/src/widgets/collections/board/context_menu.ts
+++ b/apps/client/src/widgets/collections/board/context_menu.ts
@@ -182,16 +182,18 @@ function buildColumnItems(
api: Api, note: FNote, column: string, onFocusCard: (noteId: string) => void
): MenuItem<CommandNames>[] {
return api.columns.map((name) => ({
- // The menu reads a title as markup, and a column is named by the reader, so what a crafted
- // name would plant there is escaped into the text it is meant to be. Every other title the
- // board builds from a name goes through `t()`, which escapes what it interpolates.
- title: escapeHtml(name),
+ // The menu reads a title as markup, which is what puts the name in a box of its own: a
+ // bare run of text inside the item's flex row is an anonymous box, and nothing can be said
+ // about its width. What a crafted name would plant there is escaped into the text it is
+ // meant to be; every other title the board builds from a name goes through `t()`, which
+ // escapes what it interpolates.
+ title: `<span class="board-column-name">${escapeHtml(name)}</span>`,
uiIcon: api.getColumnIcon(name),
iconColorClass: api.getColumnColorClass(name),
// The one it is already under is shown rather than hidden, so the list reads as the whole
// set of columns and says which of them this card belongs to.
trailingIcon: name === column ? "bx bx-check" : undefined,
- className: name === column ? "board-current-column" : undefined,
+ className: name === column ? "board-column-item board-current-column" : "board-column-item",
badges: api.isColumnArchived(name)
? [ { title: t("board_view.archived-badge") } ]
: undefined,
diff --git a/apps/client/src/widgets/collections/board/index.css b/apps/client/src/widgets/collections/board/index.css
index 0556f010ec..7d0bf63e01 100644
--- a/apps/client/src/widgets/collections/board/index.css
+++ b/apps/client/src/widgets/collections/board/index.css
@@ -482,8 +482,16 @@ body.mobile .board-view-container .board-add-column {
word-wrap: break-word;
}
-/* The menu is drawn outside the board, so the column a card is already under is named rather than
- reached through `.board-view`. */
+/* The menu is drawn outside the board, so the columns it lists are named rather than reached
+ through `.board-view`. */
.dropdown-item.board-current-column {
font-weight: 600;
}
+
+.dropdown-item.board-column-item .board-column-name {
+ display: block;
+ max-width: 300px;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}