From aee214ed44a866c81fc7ecfbdfc80e2874837fe0 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 11 Apr 2016 02:52:09 -0400 Subject: [PATCH] Update collection context menu once items have loaded Otherwise, when right-clicking on a collection that's not currently selected, some of the menu items appear gray at first, and a second right-click is necessary after the items have loaded. This way the menu items turn black once the items have loaded. --- chrome/content/zotero/xpcom/libraryTreeView.js | 4 ++++ chrome/content/zotero/zoteroPane.js | 15 ++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/chrome/content/zotero/xpcom/libraryTreeView.js b/chrome/content/zotero/xpcom/libraryTreeView.js index 8134abe41..bfdb1d36e 100644 --- a/chrome/content/zotero/xpcom/libraryTreeView.js +++ b/chrome/content/zotero/xpcom/libraryTreeView.js @@ -37,6 +37,10 @@ Zotero.LibraryTreeView = function () { }; Zotero.LibraryTreeView.prototype = { + get initialized() { + return this._initialized; + }, + addEventListener: function(event, listener) { if (event == 'load') { // If already initialized run now diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 1464b57aa..e70b919ed 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -2338,13 +2338,18 @@ var ZoteroPane = new function() m.loadReport ]; var s = [m.exportCollection, m.createBibCollection, m.loadReport]; + if (!this.itemsView.rowCount) { - if (!this.collectionsView.isContainerEmpty(this.collectionsView.selection.currentIndex)) { - disable = [m.createBibCollection, m.loadReport]; - } - else { - disable = s; + // If no items, it might be because this was a right-click on a different collection + // and the new collection's items are still loading, so update the menu after loading. + // This causes export/createBib/loadReport to appear gray in the menu at first and then + // turn black once there are items. + if (!this.itemsView.initialized) { + this.itemsView.addEventListener('load', function () { + this.buildCollectionContextMenu(); + }.bind(this)); } + disable = s; } // Adjust labels