Fix "this.selection is undefined" switching away from loading collection
This commit is contained in:
parent
7c3a134107
commit
bb4db297c4
|
@ -1319,11 +1319,15 @@ var ZoteroPane = new function()
|
||||||
});
|
});
|
||||||
yield deferred.promise;
|
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
|
// 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,
|
// can be called in various situations where the selection didn't actually change,
|
||||||
// such as whenever selectEventsSuppressed is set to false.
|
// such as whenever selectEventsSuppressed is set to false.
|
||||||
|
var selectedItems = this.itemsView.getSelectedItems();
|
||||||
var ids = selectedItems.map(item => item.id);
|
var ids = selectedItems.map(item => item.id);
|
||||||
ids.sort();
|
ids.sort();
|
||||||
if (ids.length && Zotero.Utilities.arrayEquals(_lastSelectedItems, ids)) {
|
if (ids.length && Zotero.Utilities.arrayEquals(_lastSelectedItems, ids)) {
|
||||||
|
@ -1331,11 +1335,6 @@ var ZoteroPane = new function()
|
||||||
}
|
}
|
||||||
_lastSelectedItems = ids;
|
_lastSelectedItems = ids;
|
||||||
|
|
||||||
if (!this.itemsView) {
|
|
||||||
Zotero.debug("Items view not available in itemSelected", 2);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Display restore/delete buttons depending on context
|
// Display restore/delete buttons depending on context
|
||||||
if (this.itemsView.selection.count) {
|
if (this.itemsView.selection.count) {
|
||||||
document.getElementById('zotero-item-pane-top-buttons-trash').hidden
|
document.getElementById('zotero-item-pane-top-buttons-trash').hidden
|
||||||
|
|
Loading…
Reference in New Issue
Block a user