I am really sorry, but I am still not seeing it in the actual code. I think I have stripped this down to have no dependencies outside the snippet, to me this looks equivalent to the standalone snippet I posted above this:
function selectedAutoExports(_mode) {
return [ { path: '/x/y' }, { path: '/foo/bar' } ]
}
Zotero.MenuManager.registerMenu({
menuID: `${pluginID}-menu-collection`,
pluginID,
target: 'main/library/collection',
menus: [
{
menuType: 'submenu',
l10nID: 'better-bibtex',
icon: 'chrome://zotero-better-bibtex/content/skin/bibtex-menu.svg',
menus: [
{
menuType: 'submenu',
l10nID: 'better-bibtex_preferences_auto-export',
onShowing: (_event, context) => {
Zotero.warn(new Error(`submenu showing: ${selectedAutoExports('any').length !== 0}`))
const type = context.collectionTreeRow.type
context.setVisible(selectedAutoExports(type).length !== 0)
},
menus: Array.from({ length: 10 }).map((_, i) => ({
menuType: 'menuitem',
onShowing: (event: Event, context) => {
Zotero.warn(new Error(`menuitem ${i} showing?`))
const type = context.collectionTreeRow.type
const aes = selectedAutoExports(type)
context.setVisible(aes.length > i)
Zotero.warn(new Error(`menuitem ${i} showing: ${aes.length > i}`))
context.menuElem.setAttribute('label', aes[i]?.path || '[path not set]')
},
/*onCommand: (_event: Event, _context) => {
const ae = selectedAutoExports('collection')[i]
if (ae) Zotero.BetterBibTeX.AutoExport.run(ae.path)
}*/,
}))/* as MenuItem[] */,
},
// { menuType: 'menuitem', l10nID: 'better-bibtex_zotero-pane_show_collection-key', onCommand: (_event, _context) => showPullExportURLs('collection') },
// { menuType: 'menuitem', l10nID: 'better-bibtex_aux-scanner', onCommand: (_event, _context) => void Zotero.BetterBibTeX.scanAUX('collection') },
// { menuType: 'menuitem', l10nID: 'better-bibtex_report-errors', onCommand: (_event, _context) => void Zotero.BetterBibTeX.ErrorReport.open('collection') },
],
},
],
})
and I don't see
menuitem ${i} showing?
where I would have expected it to. I do see
`submenu showing: true`