From d3cee95fb73af714e01bcd17ac129cacb1cfc1ba Mon Sep 17 00:00:00 2001 From: abaevbog Date: Wed, 5 Mar 2025 02:59:11 -0800 Subject: [PATCH] Click on itemBox label focus edits (#5065) Click on a label of a focused field will refocus itemTree or the reader content, depending on the tab. That way focus is not lost. Fixes: #5063 --- chrome/content/zotero/elements/attachmentBox.js | 2 +- chrome/content/zotero/elements/itemBox.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/elements/attachmentBox.js b/chrome/content/zotero/elements/attachmentBox.js index 6c04806178..853e221ac6 100644 --- a/chrome/content/zotero/elements/attachmentBox.js +++ b/chrome/content/zotero/elements/attachmentBox.js @@ -700,7 +700,7 @@ let labelWrapper = event.target.closest(".meta-label"); if (labelWrapper.nextSibling.contains(document.activeElement)) { - document.activeElement.blur(); + ZoteroPane.itemsView.focus(); } else if (!labelWrapper.nextSibling.firstChild.readOnly) { labelWrapper.nextSibling.firstChild.focus(); diff --git a/chrome/content/zotero/elements/itemBox.js b/chrome/content/zotero/elements/itemBox.js index 9129d23807..d7bdc441cc 100644 --- a/chrome/content/zotero/elements/itemBox.js +++ b/chrome/content/zotero/elements/itemBox.js @@ -1679,7 +1679,15 @@ let labelWrapper = label.closest(".meta-label"); if (labelWrapper.nextSibling.contains(document.activeElement)) { - document.activeElement.blur(); + // click on label when value field is already focused + // will refocus itemTree in library tab or reader content in reader tab + if (Zotero_Tabs.selectedType === "library") { + ZoteroPane.itemsView.focus(); + } + else { + let reader = Zotero.Reader.getByTabID(Zotero_Tabs.selectedID); + reader.focus(); + } } else { let valueField = labelWrapper.nextSibling.firstChild;