From 630eccf72f9d9688fc131b7d2ec9a824ac165524 Mon Sep 17 00:00:00 2001 From: Martynas Bagdonas Date: Mon, 29 Jan 2024 14:35:06 +0800 Subject: [PATCH] Fix context pane note back button regression Fixes #3616 --- chrome/content/zotero/contextPane.js | 39 +++++++++++++--------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/chrome/content/zotero/contextPane.js b/chrome/content/zotero/contextPane.js index 4d833cf3c4..e3591ace68 100644 --- a/chrome/content/zotero/contextPane.js +++ b/chrome/content/zotero/contextPane.js @@ -785,27 +785,24 @@ var ZoteroContextPane = new function () { editor.focus(); let parentItem = item.parentItem; - if (!parentTitleContainer.querySelector(".parent-title-container")) { - let container = document.createElement('div'); - container.classList.add("parent-title-container"); - let returnBtn = document.createXULElement("toolbarbutton"); - returnBtn.classList.add("zotero-tb-note-return"); - returnBtn.addEventListener("command", () => { - // Immediately save note content before vbox with note-editor iframe is destroyed below - editor.saveSync(); - _panesDeck.setAttribute('selectedIndex', 1); - _notesPaneDeck.selectedPanel.setAttribute('selectedIndex', 0); - vbox.remove(); - _updateAddToNote(); - _preventGlobalDeckChange = true; - }); - let title = document.createElement('div'); - title.className = 'parent-title'; - container.append(returnBtn, title); - parentTitleContainer.append(container); - } - parentTitleContainer.querySelector(".parent-title").textContent - = parentItem?.getDisplayTitle() || ""; + let container = document.createElement('div'); + container.classList.add("parent-title-container"); + let returnBtn = document.createXULElement("toolbarbutton"); + returnBtn.classList.add("zotero-tb-note-return"); + returnBtn.addEventListener("command", () => { + // Immediately save note content before vbox with note-editor iframe is destroyed below + editor.saveSync(); + _panesDeck.setAttribute('selectedIndex', 1); + _notesPaneDeck.selectedPanel.setAttribute('selectedIndex', 0); + vbox.remove(); + _updateAddToNote(); + _preventGlobalDeckChange = true; + }); + let title = document.createElement('div'); + title.className = 'parent-title'; + title.textContent = parentItem?.getDisplayTitle() || ''; + container.append(returnBtn, title); + parentTitleContainer.replaceChildren(container); _updateAddToNote(); } }