diff --git a/chrome/content/zotero/zoteroPane.js b/chrome/content/zotero/zoteroPane.js index 90b819467d..b3e41f84a2 100644 --- a/chrome/content/zotero/zoteroPane.js +++ b/chrome/content/zotero/zoteroPane.js @@ -78,6 +78,7 @@ var ZoteroPane = new function() // Set key down handler document.getElementById('appcontent').addEventListener('keydown', ZoteroPane_Local.handleKeyDown, true); + document.addEventListener('blur', ZoteroPane.handleBlur); // Init toolbar buttons for all progress queues let progressQueueButtons = document.getElementById('zotero-pq-buttons'); @@ -636,9 +637,17 @@ var ZoteroPane = new function() } } + this.handleBlur = (event) => { + if (this.highlightTimer) { + this.highlightTimer.cancel(); + this.highlightTimer = null; + } + ZoteroPane_Local.collectionsView.setHighlightedRows(); + } + function handleKeyUp(event) { var from = event.originalTarget.id; - if (from == 'zotero-items-tree') { + if (ZoteroPane.itemsView && from == ZoteroPane.itemsView.id) { if ((Zotero.isWin && event.keyCode == 17) || (!Zotero.isWin && event.keyCode == 18)) { if (this.highlightTimer) { @@ -686,7 +695,7 @@ var ZoteroPane = new function() return; } - if (from == this.itemsView.id) { + if (this.itemsView && from == this.itemsView.id) { // Focus TinyMCE explicitly on tab key, since the normal focusing doesn't work right if (!event.shiftKey && event.keyCode == event.DOM_VK_TAB) { var deck = document.getElementById('zotero-item-pane-content');