From 7fe01d6c0394e548d3d81f20c39d76022f6654f6 Mon Sep 17 00:00:00 2001 From: windingwind <33902321+windingwind@users.noreply.github.com> Date: Thu, 25 Jan 2024 10:00:41 +0800 Subject: [PATCH] Clicking filename label should focus/blur field in attachment box --- chrome/content/zotero/elements/attachmentBox.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/chrome/content/zotero/elements/attachmentBox.js b/chrome/content/zotero/elements/attachmentBox.js index 7d2af9320c..3d9a6f6363 100644 --- a/chrome/content/zotero/elements/attachmentBox.js +++ b/chrome/content/zotero/elements/attachmentBox.js @@ -263,6 +263,8 @@ reindexButton.click(); } }); + + this.querySelectorAll(".meta-label").forEach(label => label.addEventListener("click", this._handleMetaLabelClick)); } destroy() { @@ -622,6 +624,16 @@ await this.item.saveTx(); } + _handleMetaLabelClick = (event) => { + let labelWrapper = event.target.closest(".meta-label"); + if (labelWrapper.nextSibling.contains(document.activeElement)) { + document.activeElement.blur(); + } + else if (!labelWrapper.nextSibling.firstChild.readOnly) { + labelWrapper.nextSibling.firstChild.focus(); + } + }; + _id(id) { return this.querySelector(`#${id}`); }