Skip to content

Build your personal knowledge base with Trilium Notes

feat(collections/table): right-align number columns

Elian Doran56528b966098
diff --git a/apps/client/src/widgets/collections/table/columns.spec.ts b/apps/client/src/widgets/collections/table/columns.spec.ts
index ff9d8a7666..6cbc7b4b58 100644
--- a/apps/client/src/widgets/collections/table/columns.spec.ts
+++ b/apps/client/src/widgets/collections/table/columns.spec.ts
@@ -205,6 +205,19 @@ describe("buildColumnDefinitions — typed columns", () => {
expect(classOf("text")).toBeUndefined();
});
+ it("right-aligns a number column, header included, so that its digits line up by place", () => {
+ const columns = buildColumnDefinitions({
+ info: [ { name: "number", type: "number" }, { name: "date", type: "date" } ],
+ movableRows: false,
+ existingColumnData: undefined,
+ rowNumberHint: 1
+ });
+ const columnOf = (name: string) => columns.find((column) => column.field === `labels.${name}`);
+
+ expect(columnOf("number")).toMatchObject({ hozAlign: "right", headerHozAlign: "right" });
+ expect(columnOf("date")?.hozAlign).toBeUndefined();
+ });
+
it("hands a url column's href through the scheme guard rather than linking the value as stored", () => {
const column = buildColumnDefinitions({
info: [ { name: "site", type: "url" } ],
diff --git a/apps/client/src/widgets/collections/table/columns.tsx b/apps/client/src/widgets/collections/table/columns.tsx
index b33af3b5ed..055b9369a6 100644
--- a/apps/client/src/widgets/collections/table/columns.tsx
+++ b/apps/client/src/widgets/collections/table/columns.tsx
@@ -74,6 +74,8 @@ const labelTypeMappings: Record<ColumnType, Partial<ColumnDefinition>> = {
number: {
editor: "number",
cssClass: NUMERIC_CELL_CLASS,
+ hozAlign: "right",
+ headerHozAlign: "right",
sorter: "number"
},
time: {