From 3566d1fc1fb5e9895b96ef71eeadcc6e4488c165 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Wed, 25 May 2022 12:51:15 -0600 Subject: [PATCH] fx-compat: Item box: Fix item type menulist - Use IDs as list item values - Use addEventListener() so events are actually received - Put menulist inside * This causes a small appearance regression at the moment because margins/padding are a bit off, but that issue is visible on all other fields already. --- chrome/content/zotero/elements/itemBox.js | 18 ++++++++++-------- .../zotero/elements/menulistItemTypes.js | 4 ++-- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/chrome/content/zotero/elements/itemBox.js b/chrome/content/zotero/elements/itemBox.js index ca3906fe72..65a10852f5 100644 --- a/chrome/content/zotero/elements/itemBox.js +++ b/chrome/content/zotero/elements/itemBox.js @@ -752,26 +752,28 @@ } addItemTypeMenu() { + var td = document.createElement('td'); var menulist = document.createXULElement("menulist", { is: "menulist-item-types" }); menulist.id = "item-type-menu"; menulist.className = "zotero-clicky"; - menulist.onCommand = (event) => { + menulist.addEventListener('command', (event) => { var target = event.target; this.changeTypeTo(target.value, target); - }; - menulist.onFocus = (event) => { + }); + menulist.addEventListener('focus', () => { this.ensureElementIsVisible(menulist); - }; - menulist.onKeyPress = (event) => { + }); + menulist.addEventListener('keypress', (event) => { if (event.keyCode == event.DOM_VK_TAB) { this.itemTypeMenuTab(event); } - }; - this._infoTable.firstChild.appendChild(menulist); + }); + td.appendChild(menulist); + this._infoTable.firstChild.appendChild(td); } updateItemTypeMenuSelection() { - this.itemTypeMenu.value = this.item.itemType; + this.itemTypeMenu.value = this.item.itemTypeID; } addDynamicRow(label, value, beforeElement) { diff --git a/chrome/content/zotero/elements/menulistItemTypes.js b/chrome/content/zotero/elements/menulistItemTypes.js index d3f62a3b29..c6fd88bff0 100644 --- a/chrome/content/zotero/elements/menulistItemTypes.js +++ b/chrome/content/zotero/elements/menulistItemTypes.js @@ -54,7 +54,7 @@ var itemTypes = []; for (let i = 0; i < t.length; i++) { itemTypes.push({ - name: t[i].name, + id: t[i].id, localized: Zotero.ItemTypes.getLocalizedString(t[i].id) }); } @@ -64,7 +64,7 @@ for (let i = 0; i < itemTypes.length; i++) { let name = itemTypes[i].name; if (name != 'attachment' && name != 'note' && name != 'annotation') { - this.appendItem(itemTypes[i].localized, itemTypes[i].name); + this.appendItem(itemTypes[i].localized, itemTypes[i].id); } }