Submenu items on a context menu

I’m using this functionality for creating a context menu. It’s documented for XD but also works for PS.

I’m not successful with creating submenus.

This seems not to work:

<menu>
    <menuitem label="Menu">
        <menu>
            <menuitem label="Submenu"></menuitem>
        </menu>
    </menuitem>
</menu>

Is it even possible?

1 Like

For XD, use a <menu label="Submenu">, rather than a <menu> inside a <menuitem>.

It does not appear this is wired up in Ps. None of our features have needed nested submenus, so it’s likely never come up.

None of our features have needed nested submenus, so it’s likely never come up.

:open_mouth:
I thought you also develop features for third party developers and not only for “your features”.

And if it works in XD why it will not be implemented in PS? I also thought you want almost the same behaviour in all host apps …

You don’t think it will be helpful for having submenus on a right click context menu?

Kerri, I think I misunderstood you as saying “so it will probably never come up”. I understood it as “we never needed it, so it won’t come up (in the future)”. You probably meant that’s why it hasn’t been implemented in the past?

The latter, yes; if there’s no code exercising that path, it’s easy for it to be missed. I do note that although submenus work in XD, I don’t see that submenu support is doc’d anywhere, so submenu support was just luck that the developer thought to add it. Because PS is a different backend, everything has to be wired up again. This will change when we move to a new UI compositing engine in the next few months (this is why some elements will become deprecated in favor of Spectrum UXP). Once that happens, parity is much easier, because we don’t have to have a unique back-end for every single app. That will also unblock animations, transforms, better z-order stacking, etc.

Totally see the value of submenus, of course – just that there’s no test for it, and so it’s easy for one app backend to do “the bare minimum” to support what they know is running on them, and end up with inconsistencies.

Definitely not ruling out submenu support in the future.