From ef7896ab5f79fe8436cd5f4a96e7821baa76dfe2 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Wed, 29 Apr 2026 15:21:57 -0400 Subject: [PATCH] Fix lost item tree column choices after item tree refactor Before the refactor, main library column prefs were keyed under "-default", because the visibilityGroup getter returns 'default' (truthy) for the main library. The refactor changed the suffix logic to only append non-default groups, leaving existing prefs orphaned at "-default" while the new code reads/writes "". Fall back to the legacy key on load when the new key is missing or an empty object (which can be written out by an unmodified post-refactor build that flushed prefs on a visibility-group switch, like switching to feeds), and drop the legacy key on the next write. https://forums.zotero.org/discussion/131202/lost-columns-displayed-choice-in-the-items-tree-after-update-to-10-beta-4 --- chrome/content/zotero/itemTree.jsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/itemTree.jsx b/chrome/content/zotero/itemTree.jsx index 8c7ed837e3..3d22afb740 100644 --- a/chrome/content/zotero/itemTree.jsx +++ b/chrome/content/zotero/itemTree.jsx @@ -2395,7 +2395,15 @@ var ItemTree = class ItemTree extends LibraryTree { try { let columnPrefs = await Zotero.File.getContentsAsync(COLUMN_PREFS_FILEPATH); let persistSettings = JSON.parse(columnPrefs); - this._columnPrefs = persistSettings[this.id] || {}; + // Fall back to the pre-item-tree-refactor "-default" key, + // including when "" is an empty object written out by an + // earlier post-refactor beta before this fallback was added. + // _writeColumnPrefsToFile() removes it on the next write. + let prefs = persistSettings[this.id]; + if (!prefs || !Object.keys(prefs).length) { + prefs = persistSettings[this.id + '-default']; + } + this._columnPrefs = prefs || {}; } catch (e) { this._columnPrefs = {}; @@ -2419,6 +2427,7 @@ var ItemTree = class ItemTree extends LibraryTree { persistSettings = {}; } persistSettings[this.id] = this._columnPrefs; + delete persistSettings[this.id + '-default']; let prefString = JSON.stringify(persistSettings); Zotero.debug(`Writing column prefs of length ${prefString.length} to file ${COLUMN_PREFS_FILEPATH}`);