Skip to content

Build your personal knowledge base with Trilium Notes

fix(table): re-widen the row number column past 99 rows (closes #11590)

Elian Doran4159c782fd49
diff --git a/apps/client/src/widgets/collections/table/columns.spec.ts b/apps/client/src/widgets/collections/table/columns.spec.ts
index 4ab639021a..d257a38806 100644
--- a/apps/client/src/widgets/collections/table/columns.spec.ts
+++ b/apps/client/src/widgets/collections/table/columns.spec.ts
@@ -148,6 +148,20 @@ describe("restoreExistingData", () => {
const restored = restoreExistingData(newDefs, oldDefs);
expect(restored[0].width).toStrictEqual("100px");
});
+
+ it("enforces size for non-resizable columns persisted by Tabulator", () => {
+ // Tabulator's persistence stores only `title`, `width` and `visible`, so a stored "#"
+ // column carries no `resizable` flag. Restoring its width would pin the column to the
+ // digit count the table had when it was last persisted.
+ const newDefs: ColumnDefinition[] = [
+ { title: "#", resizable: false, width: 80 }
+ ];
+ const oldDefs: ColumnDefinition[] = [
+ { title: "#", width: 48, visible: true }
+ ];
+ const restored = restoreExistingData(newDefs, oldDefs);
+ expect(restored[0].width).toStrictEqual(80);
+ });
});
describe("buildColumnDefinitions — typed columns", () => {
diff --git a/apps/client/src/widgets/collections/table/columns.tsx b/apps/client/src/widgets/collections/table/columns.tsx
index dc6d0fd7de..aae394ec88 100644
--- a/apps/client/src/widgets/collections/table/columns.tsx
+++ b/apps/client/src/widgets/collections/table/columns.tsx
@@ -232,7 +232,11 @@ export function restoreExistingData(newDefs: ColumnDefinition[], oldDefs: Column
.filter(item => (item.field && newItemsByField.has(item.field!)) || item.title === "#")
.map(oldItem => {
const data = newItemsByField.get(oldItem.field!)!;
- if (oldItem.resizable !== false && oldItem.width !== undefined) {
+ // Whether a column can be resized is read from the new definition: Tabulator persists
+ // only `title`, `width` and `visible`, so the stored one never carries the flag. The "#"
+ // column sizes itself to the row count's digits and must keep that width rather than the
+ // one stored when the table held fewer rows.
+ if (data.resizable !== false && oldItem.width !== undefined) {
data.width = oldItem.width;
}
if (oldItem.visible !== undefined) {