New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request - get electron MenuItem by ID #10440

sibiraj-s opened this Issue Sep 5, 2017 · 3 comments


None yet
4 participants

sibiraj-s commented Sep 5, 2017

  • Electron version: 1.7.5
  • Operating system: All

Expected behavior

From this #937 issue, I came to know that MenuItem's enabled, checked and visible property can be set dynamically.

Also, from the docs, it is mentioned that id of the menu can be used only with positioning of menu

Why not something like this?

    label: 'View',
    submenu: [
        label: 'Enter Fullscreen',
        accelerator: 'Control+Command+F',
        id: 'fullScreen',
        click: function() {
        label: 'Exit Fullscreen',
        accelerator: 'Control+Command+F',
        click: function() {

Instead of doing
menu.items[1].submenu.items[0].enabled = false;


let myElm = Menu.getMenuItemById('fullScreen');
myElm.enabled = true/false

This comment has been minimized.

welcome bot commented Sep 5, 2017

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.


This comment has been minimized.

tonioloewald commented Sep 6, 2017

Being able to obtain menu items by id would be very useful.

It would be pretty easy to write:

const getMenuItemById = (items, id) => {
  if (items instanceof Menu) {
    items = items.items;
  let found = items.find(item => === id) || false;
  for(let i = 0, length = items.length; !found && i < length; i++) {
    if (items[i].submenu) {
      found = getMenuItemById(items[i].submenu, id);
  return found;

This comment has been minimized.


codebytere commented Sep 27, 2017

Feature has been added!

@codebytere codebytere closed this Sep 27, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment