View Full Version : 6.5.2 classic: Ext.ux.desktop.Desktop.onDesktopMenuBeforeShow() enabled status issue

4 Oct 2017, 1:03 PM
The Ext.ux.desktop.Desktop.onDesktopMenuBeforeShow() code (http://docs.sencha.com/extjs/6.5.2/classic/src/Desktop.js.html#line185) always enables menu entries, even if they are custom menu entries that do not depend on the amount of windows displayed.

The code is pretty straightforward so I didn't bother making a test case, I'm sure you'll understand as soon as you just read the code.

For instance, this would be enough to address the issue and only fiddle with the menu entries' enabled status if the minWindows is set:

Ext.define("gh1559", {
override: "Ext.ux.desktop.Desktop",
onDesktopMenuBeforeShow: function (menu) {
var me = this, count = me.windows.getCount();

menu.items.each(function (item) {
if (Ext.isDefined(item.minWindows)) {
var min = item.minWindows || 0;
item.setDisabled(count < min);

A test case would just involve a desktop with a custom menu entry. Give the menu an ID then after the page is rendered, try to disable it from console, say Ext.get('myMenuEntry').setDisabled(true), then show the desktop's context menu: the menu entry will be enabled.

Notice the "custom menu entry" will not have its "minWindows" defined at creation time, so it will be undefined while the event steps thru all the menu entries.