From 1e7542569886feea11bdb40144949ddb90a950f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adomas=20Ven=C4=8Dkauskas?= Date: Tue, 16 Jun 2020 12:26:20 +0300 Subject: [PATCH] Fix highlighted collection not unhighlighting --- chrome/content/zotero/zoteroPane.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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');