# \[BUG\] Panel menuItems.removeAt() doesn't work with submenus

**URL:** <https://forums.creativeclouddeveloper.com/t/bug-panel-menuitems-removeat-doesnt-work-with-submenus/9405>\
**Category:** Photoshop\
**Tags:** bug, uxp, javascript\
**Created:** [February 16, 2025, 8:18pm UTC](https://forums.creativeclouddeveloper.com/t/bug-panel-menuitems-removeat-doesnt-work-with-submenus/9405 "2025-02-16T20:18:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [February 16, 2025, 8:18pm UTC](https://forums.creativeclouddeveloper.com/t/bug-panel-menuitems-removeat-doesnt-work-with-submenus/9405/1 "2025-02-16T20:18:46Z")

</div>

This is an actual blocker with no workaround 😞

* * *

Having as simple menu as this:

```json
[
    {id: "menu1", label: "Menu 1"},
    {
        id: "submenu", label: "Submenu",
        submenu: [
            {id: "submenu1",label: "Submenu 1"},
        ],
    },
    {id: "menu2",label: "Menu 2"},
]

```

After `entrypoints.setup()` everything works as expected.

Remove `submenu`. Seems that it works as expected, and item is gone, but actually it doesn’t work and it is still somewhere in the memory.

Trying to create menu with same IDs in the submenu, error is thrown, that item with the same ID already exists.Trying to add back `submenu` item, there’s an error, that `submenu1` already exists. Even though trying to get that item, it returns `null`. And there’s no way to remove only submenu items specifically

* * *

Add these to UXP Dev Tools playground to test:

- HTML

```html
<!DOCTYPE html>
<html>
  <head><script src="main.js"></script></head>
  <body><sp-body>PANEL</sp-body></body>
</html>

```

- JS

```js
const { entrypoints } = require("uxp")

const flyoutMenu = [
    {id: "menu1", label: "Menu 1"},
    {
        id: "submenu", label: "Submenu",
        submenu: [
            {id: "submenu1",label: "Submenu 1"},
        ],
    },
    {id: "menu2",label: "Menu 2"},
]

entrypoints.setup({
    panels: {
        "vanilla": {
            menuItems: flyoutMenu,
            show: () => {},
        }
    }
})

let { menuItems } = entrypoints.getPanel("vanilla")
console.log("INIT", menuItems.size)

menuItems.removeAt(1)
console.log("REMOVE", menuItems.size)

console.log("GET", menuItems.getItem("submenu1"))

menuItems.insertAt(2, flyoutMenu[1])
console.log("INSERT", menuItems.size)

```

- Manifest

```json
{
    "id": "com.adobe.example.vanilla-ps-js",
    "name": "Starter Panel",
    "version": "1.0.0",
    "main": "index.html",
    "host": {
        "app": "PS",
        "minVersion": "23.0.0",
        "data": {
            "apiVersion": 2
        }
    },
    "manifestVersion": 5,
    "entrypoints": [
        {
            "type": "command",
            "id": "showAlert",
            "label": "Show alert"
        },
        {
            "type": "panel",
            "id": "vanilla",
            "minimumSize": {"width": 230, "height": 200},
            "maximumSize": {"width": 2000, "height": 2000},
            "preferredDockedSize": {"width": 230, "height": 300},
            "preferredFloatingSize": {"width": 230, "height": 300},
            "icons": [
                { "width": 32, "height": 32, "path": "icons/icon_D.png", "scale": [1, 2], "theme": ["dark", "darkest"], "species": ["generic"] },
                { "width": 32, "height": 32, "path": "icons/icon_N.png", "scale": [1, 2], "theme": ["lightest", "light"], "species": ["generic"] }
            ],
            "label": {"default": "Starter Panel"}
        }
    ],
    "icons": [
        {
            "width": 23, "height": 23, "path": "icons/dark.png", "scale": [1, 2],
            "theme": ["darkest", "dark", "medium"]
        }, {
            "width": 23, "height": 23, "path": "icons/light.png", "scale": [1, 2],
            "theme": ["lightest", "light"]
        }
    ]
}

```

---

<div class="post-metadata">

**Author:** ![Karmalakas](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/karmalakas/32/1048_2.png) [@Karmalakas](https://forums.creativeclouddeveloper.com/u/Karmalakas)\
**Post date:** [March 24, 2025, 9:51am UTC](https://forums.creativeclouddeveloper.com/t/bug-panel-menuitems-removeat-doesnt-work-with-submenus/9405/2 "2025-03-24T09:51:25Z")

</div>

Apparently there are [more issues](https://forums.creativeclouddeveloper.com/t/bug-cant-change-properties-of-flyout-menu-items-that-have-submenus/10435) with flyout submenus.

@Erin_Finnegan, would you be so kind to redirect these to the correct team? ☹
