diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 9ea18db65f..1464b57aab 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -1319,11 +1319,15 @@ var ZoteroPane = new function() }); yield deferred.promise; - var selectedItems = this.itemsView.getSelectedItems(); + if (!this.itemsView || !this.itemsView.selection) { + Zotero.debug("Items view not available in itemSelected", 2); + return false; + } // Check if selection has actually changed. The onselect event that calls this // can be called in various situations where the selection didn't actually change, // such as whenever selectEventsSuppressed is set to false. + var selectedItems = this.itemsView.getSelectedItems(); var ids = selectedItems.map(item => item.id); ids.sort(); if (ids.length && Zotero.Utilities.arrayEquals(_lastSelectedItems, ids)) { @@ -1331,11 +1335,6 @@ var ZoteroPane = new function() } _lastSelectedItems = ids; - if (!this.itemsView) { - Zotero.debug("Items view not available in itemSelected", 2); - return false; - } - // Display restore/delete buttons depending on context if (this.itemsView.selection.count) { document.getElementById('zotero-item-pane-top-buttons-trash').hidden