From eb33fa583564b93212960016a5159ea8dba6c330 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Fri, 28 Aug 2026 11:27:17 -0400 Subject: [PATCH] Move the checkmark to the activated target in createMenuForTarget() The target menu isn't rebuilt between openings, so the checkmark stayed on the target the menu was built with. In the New Collection dialog, whose menu belongs to a menulist, that would leave two checkmarks if you clicked a different collection and then reopened the menu. --- .../zotero/xpcom/utilities_internal.js | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/utilities_internal.js b/chrome/content/zotero/xpcom/utilities_internal.js index bb6838c837..5b9bccb3c6 100644 --- a/chrome/content/zotero/xpcom/utilities_internal.js +++ b/chrome/content/zotero/xpcom/utilities_internal.js @@ -1821,6 +1821,24 @@ Zotero.Utilities.Internal = { return menu; } + // The menu isn't rebuilt between openings, so move the checkmark to the target + // that's activated. A marks the item clicked in its own popup as + // selected, drawing a checkmark of its own, and can't clear it when the next + // pick is in a submenu, so clear that too. + function _setCurrentTarget(target) { + if (!currentTarget) { + return; + } + for (let menuitem of elem.querySelectorAll('menuitem[checked], menuitem[selected]')) { + menuitem.removeAttribute('checked'); + menuitem.removeAttribute('selected'); + } + let menuitem = elem.querySelector(`menuitem[value="${target.treeViewID}"]`); + if (menuitem) { + menuitem.setAttribute('checked', 'true'); + } + } + function _appendTarget(target, parent) { let collections = target.objectType == 'collection' ? Zotero.Collections.getByParent(target.id) @@ -1834,7 +1852,10 @@ Zotero.Utilities.Internal = { return null; } - let command = event => clickAction(event, target); + let command = (event) => { + _setCurrentTarget(target); + clickAction(event, target); + }; let imageSrc = target.treeViewImage; // Create menuitem for library or collection itself, to be placed either directly in