From bb4db297c490d642b294e6ef04d9fa521c20d482 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 11 Apr 2016 02:29:25 -0400 Subject: [PATCH] Fix "this.selection is undefined" switching away from loading collection --- chrome/content/zotero/zoteroPane.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 9ea18db65..1464b57aa 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