Can't programmatically change the name (i.e. the "label" property) of fly-out menu group names

This is in reference to @DavideBarranca’s excellent video on UXP panel fly-out menus: https://www.youtube.com/watch?v=v-x1ZrOtlzQ

At around 15:25 he discusses changing the value of the “label” property to change the name of a menu item.

However, this does NOT work for all menu items. Take the “Preferences” item in the image below. It’s the group name for a submenu of additional items. What if you wanted to change it to “Options” when you clicked one of the menu items.

fly-out

When this item was constructed in this video, no “id” was assigned to it, so in order to change the items name by the method discussed in the video, the menu item’s description would have to be given an id, something like:

{id: "preferences", label: "Preferences", submenu:
[
...
] 
}

Then, for example, to change the label from “Preferences” to “Options” when clicking the “About” item, which has the following description on the fly-out menu

{id: "about", label : "About"}'

would require something like the following in the click handler

switch(id) {
case "about":
menuItems.getItem("preferences").label = "Options";
break;
}

However, this does NOT work. The menuItems object when output via console.log shows that the _label property for the _id of “preferences” does indeed equal “Options” now, but this is NOT displayed on the fly-out menu. The fly-out menu still says “Preferences”. What this means is that whatever is initially assigned to this group menu item in the fly-out menu cannot be programmatically changed later on. The submenu items in the group CAN have their names changed by updating the “label” propery, but the group name itself cannot be changed.

This is a problem for me because when I change the language of my panel, all the menu items need to be updated to the new translation for that menu item. And this works for all the other items except for one group name that I’ve found no way to change. It’s clear in examining the menuItems object via console.log that the change is happening internally, but it’s not being reflected in the actual fly-out menu.

Sounds like a bug, IMO. And if not, something that should be documented.

cc @pkrishna @Sujai

Hi @AnthonyK,

I remember that flyout were quite finicky, to say the least… at the moment I don’t recall, but isn’t there a simpler way to provide localised strings?