<p dir="auto">If you create a MenuItem with a <code class="notranslate">role</code> it will not respect the <code class="notranslate">enabled</code> property.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="electronMenu.append(new electron.remote.MenuItem({
    type: 'normal',
    label: 'Cut',
    role: 'cut',
    accelerator: 'CommandOrControl+X',
    enabled: false, // this does nothing
}));"><pre class="notranslate"><code class="notranslate">electronMenu.append(new electron.remote.MenuItem({
    type: 'normal',
    label: 'Cut',
    role: 'cut',
    accelerator: 'CommandOrControl+X',
    enabled: false, // this does nothing
}));
</code></pre></div>
<p dir="auto">You can see that the Cut menu item is still enabled:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/62191/17564061/f856b37a-5ee6-11e6-9ba5-7c8c66a3d542.png"><img width="232" alt="screen shot 2016-08-10 at 10 40 52 am" src="https://cloud.githubusercontent.com/assets/62191/17564061/f856b37a-5ee6-11e6-9ba5-7c8c66a3d542.png" style="max-width: 100%;"></a></p>
<p dir="auto">Here it is without the role:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="electronMenu.append(new electron.remote.MenuItem({
    type: 'normal',
    label: 'Cut',
    accelerator: 'CommandOrControl+X',
    enabled: false, // this works now
}));"><pre class="notranslate"><code class="notranslate">electronMenu.append(new electron.remote.MenuItem({
    type: 'normal',
    label: 'Cut',
    accelerator: 'CommandOrControl+X',
    enabled: false, // this works now
}));
</code></pre></div>
<p dir="auto">And you can see it is now disabled:</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/62191/17564083/16164182-5ee7-11e6-95b7-2b91dfc05bf5.png"><img width="229" alt="screen shot 2016-08-10 at 10 41 57 am" src="https://cloud.githubusercontent.com/assets/62191/17564083/16164182-5ee7-11e6-95b7-2b91dfc05bf5.png" style="max-width: 100%;"></a></p>
- Electron version: 1.3.3
- Operating system: macOS
<p dir="auto">Run the below and notice that the <code class="notranslate">Select All</code> menu item is enabled even though <code class="notranslate">enabled: false</code> is specified. Remove <code class="notranslate">role: 'selectall'</code> and it's correctly disabled. The <code class="notranslate">enabled</code> option should override the <code class="notranslate">role</code>. I need this so I can enable some role based menu items only in some cases.</p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="const electron = require('electron');

electron.app.on('ready', () =&gt; {
    electron.Menu.setApplicationMenu(electron.Menu.buildFromTemplate([{
        submenu: [{
            label: 'Select All',
            role: 'selectall',
            enabled: false
        }]
    }]));

    (new electron.BrowserWindow())
        .loadURL(`https://github.com`);
});"><pre class="notranslate"><span class="pl-k">const</span> <span class="pl-s1">electron</span> <span class="pl-c1">=</span> <span class="pl-en">require</span><span class="pl-kos">(</span><span class="pl-s">'electron'</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-s1">electron</span><span class="pl-kos">.</span><span class="pl-c1">app</span><span class="pl-kos">.</span><span class="pl-en">on</span><span class="pl-kos">(</span><span class="pl-s">'ready'</span><span class="pl-kos">,</span> <span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-c1">=&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-s1">electron</span><span class="pl-kos">.</span><span class="pl-c1">Menu</span><span class="pl-kos">.</span><span class="pl-en">setApplicationMenu</span><span class="pl-kos">(</span><span class="pl-s1">electron</span><span class="pl-kos">.</span><span class="pl-c1">Menu</span><span class="pl-kos">.</span><span class="pl-en">buildFromTemplate</span><span class="pl-kos">(</span><span class="pl-kos">[</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">label</span>: <span class="pl-s">'Select All'</span><span class="pl-kos">,</span>
            <span class="pl-c1">role</span>: <span class="pl-s">'selectall'</span><span class="pl-kos">,</span>
            <span class="pl-c1">enabled</span>: <span class="pl-c1">false</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-k">new</span> <span class="pl-s1">electron</span><span class="pl-kos">.</span><span class="pl-c1">BrowserWindow</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span>
        <span class="pl-kos">.</span><span class="pl-en">loadURL</span><span class="pl-kos">(</span><span class="pl-s">`https://github.com`</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>
<h2 dir="auto"></h2>
<ul dir="auto">
<li>Electron version: 1.2.0</li>
<li>Operating system: OS X 10.11.5</li>
</ul>