Unhide "title" column on "Restore Column Order" (#5299)

This actually checks for a "primary" column, so if an extension hides the "title" column but provides its own "primary" column, the "title" column remains hidden.
This commit is contained in:
Tom Najdek 2025-05-15 13:48:25 +02:00 committed by Dan Stillman
parent 1c2ec3fd75
commit 7ffd1d4504

View file

@ -1692,6 +1692,16 @@ var Columns = class {
}
}
this._columns.sort((a, b) => a.ordinal - b.ordinal);
// Recover from scenarios where a plugin disables the "title" column and
// does not provide its own primary column, or is later removed and the
// "title" column is never restored.
let hasPrimaryColumn = this._columns.some(c => c.primary && !c.hidden);
if (!hasPrimaryColumn) {
Zotero.debug(`VirtualizedTable: Missing primary column, re-enabling the "title" column.`);
this._columns.find(c => c.dataKey === 'title').hidden = false;
}
this._adjustColumnWidths();
this.onResize(Object.fromEntries(this._columns.map(c => [c.dataKey, c.width])));
this._storePrefs(prefs);