<ul dir="auto">
<li>
<p dir="auto">Electron version: 2.0.0</p>
</li>
<li>
<p dir="auto">Operating system: MacOS 10.13.4</p>
</li>
<li>
<p dir="auto">Last known working Electron version: 1.8.4</p>
</li>
</ul>
<h3 dir="auto">Expected behavior</h3>
<p dir="auto">When a submenu item is initialized with <code class="notranslate">visible: false</code>, it should be retrievable with <code class="notranslate">getMenuItemById</code> or by iterating through <code class="notranslate">menu.items</code>.</p>
<h3 dir="auto">Actual behavior</h3>
<p dir="auto">Those items can't be found</p>
<h3 dir="auto">How to reproduce</h3>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="{
      label: 'View',
      submenu: [
        {
          id: 'show-teammates-bar',
          label: 'Show Teammates Sidebar',
          type: 'checkbox',
          visible: false,
          checked: true,
          click() {
            ...
          },
        },
        {
          type: 'separator',
        },
       {
          label: 'Show All',
          selector: 'unhideAllApplications:',
        }
      ],
    };"><pre class="notranslate"><span class="pl-kos">{</span>
      <span class="pl-c1">label</span>: <span class="pl-s">'View'</span><span class="pl-kos">,</span>
      <span class="pl-c1">submenu</span>: <span class="pl-kos">[</span>
        <span class="pl-kos">{</span>
          <span class="pl-c1">id</span>: <span class="pl-s">'show-teammates-bar'</span><span class="pl-kos">,</span>
          <span class="pl-c1">label</span>: <span class="pl-s">'Show Teammates Sidebar'</span><span class="pl-kos">,</span>
          <span class="pl-c1">type</span>: <span class="pl-s">'checkbox'</span><span class="pl-kos">,</span>
          <span class="pl-c1">visible</span>: <span class="pl-c1">false</span><span class="pl-kos">,</span>
          <span class="pl-c1">checked</span>: <span class="pl-c1">true</span><span class="pl-kos">,</span>
          <span class="pl-en">click</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
            ...
          <span class="pl-kos">}</span><span class="pl-kos">,</span>
        <span class="pl-kos">}</span><span class="pl-kos">,</span>
        <span class="pl-kos">{</span>
          <span class="pl-c1">type</span>: <span class="pl-s">'separator'</span><span class="pl-kos">,</span>
        <span class="pl-kos">}</span><span class="pl-kos">,</span>
       <span class="pl-kos">{</span>
          <span class="pl-c1">label</span>: <span class="pl-s">'Show All'</span><span class="pl-kos">,</span>
          <span class="pl-c1">selector</span>: <span class="pl-s">'unhideAllApplications:'</span><span class="pl-kos">,</span>
        <span class="pl-kos">}</span>
      <span class="pl-kos">]</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">In this example, <code class="notranslate">show-teammates-bar</code> can't be retrieved, but if initialized with <code class="notranslate">visible: true</code>, and set to <code class="notranslate">false</code> once build, it works as expected.</p>
<p dir="auto">With Electron <code class="notranslate">1.8</code>, it was possible to create an <em>invisible</em> menu item in the application menu and, assuming it was still enabled, it could be invoked via its accelerator key. This provided a mechanism for creating application-wide shortcut keys that were independent from content.</p>
<p dir="auto">For example, this menu-item template worked just fine:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="            {
                visible: false,
                accelerator: &quot;F12&quot;,
                click: () =&gt; {
                    mainWindow.webContents.openDevTools({ mode: &quot;detach&quot; });
                }
            },"><pre class="notranslate"><code class="notranslate">            {
                visible: false,
                accelerator: "F12",
                click: () =&gt; {
                    mainWindow.webContents.openDevTools({ mode: "detach" });
                }
            },
</code></pre></div>
<p dir="auto">Since upgrading to <code class="notranslate">Electron2.0.0-beta.1</code>, this no longer works. Instead, I have to make the menu item visible and give it a name in order for it to be triggered by its accelerator key:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="            {
                visible: true,
                label: &quot;Developer Tools&quot;,
                accelerator: &quot;F12&quot;,
                click: () =&gt; {
                    mainWindow.webContents.openDevTools({ mode: &quot;detach&quot; });
                }
            },"><pre class="notranslate"><code class="notranslate">            {
                visible: true,
                label: "Developer Tools",
                accelerator: "F12",
                click: () =&gt; {
                    mainWindow.webContents.openDevTools({ mode: "detach" });
                }
            },
</code></pre></div>
<p dir="auto">Is this just a regression or is this by design? If it is by design, is there any way to achieve window-level shortcut keys without resorting to nasty <code class="notranslate">keydown</code> and <code class="notranslate">keyup</code> handlers on the content level?</p>