Skip to content

Commit

Permalink
fix(menus): Do not create menu item if parent cannot be found
Browse files Browse the repository at this point in the history
  • Loading branch information
dvanoni committed Aug 25, 2024
1 parent feddb28 commit b339fcc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/content/services/ui-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ export class UIManager implements Service {
parentId: string;
window: Zotero.ZoteroWindow;
}): XUL.MenuItemElement | null {
let menuItem = createXULElement(window.document, 'menuitem');
menuItem.setAttribute('label', getLocalizedString(labelName));
menuItem.addEventListener('command', onCommand);

const parentMenu = window.document.getElementById(parentId);
if (!parentMenu) {
logger.error(`Failed to find element '${parentId}'`);
return null;
}

let menuItem = createXULElement(window.document, 'menuitem');
menuItem.setAttribute('label', getLocalizedString(labelName));
menuItem.addEventListener('command', onCommand);

menuItem = parentMenu.appendChild(menuItem);
this.addManagedNode(window, menuItem);

Expand Down

0 comments on commit b339fcc

Please sign in to comment.