# \[BUG\] performMenuCommand() inside executeAsModal() does not work with negative commands

**URL:** <https://forums.creativeclouddeveloper.com/t/bug-performmenucommand-inside-executeasmodal-does-not-work-with-negative-commands/4991>\
**Category:** UXP Plugin API\
**Tags:** bug, uxp, javascript, api-feedback\
**Created:** [July 21, 2022, 5:56pm UTC](https://forums.creativeclouddeveloper.com/t/bug-performmenucommand-inside-executeasmodal-does-not-work-with-negative-commands/4991 "2022-07-21T17:56:43Z")\
**Posts on this page:** 1\
**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:** [July 21, 2022, 5:56pm UTC](https://forums.creativeclouddeveloper.com/t/bug-performmenucommand-inside-executeasmodal-does-not-work-with-negative-commands/4991/1 "2022-07-21T17:56:43Z")

</div>

Noticed this on:  
Win10  
Manifest v4  
Api v2  
Ps v23.3.2, v23.4.2, v23.5 (beta)

Run this in console multiple times (change `["menuBarInfo"]["submenu"][10]["submenu"][3]["submenu"][1]` path to some 3rd party plugin menu command - these are negative - which would change app state):

```javascript
const photoshop = require("photoshop");

const getMenuItem = () => {
    return photoshop.action.batchPlay([{
        "_obj": "get",
        "_target": [
            {"_property": "menuBarInfo"},
            {"_ref": "application", "_enum": "ordinal", "_value": "targetEnum"},
        ],
        "_options": {"dialogOptions": "dontDisplay"}
    }], {synchronousExecution: true})[0]["menuBarInfo"]["submenu"][10]["submenu"][3]["submenu"][1]
}

// await photoshop.core.executeAsModal(async () => {
    const menuItem = getMenuItem()
    console.log(menuItem)

    photoshop.core.performMenuCommand({
        commandId: menuItem.command,
        kcanDispatchWhileModal: true,
        _isCommand: false
    });

    console.log(getMenuItem())
// }, {commandName: "Command"})

```

You will notice that menu item before command and after have same negative command ID always. Now uncomment both lines where script is wrapped in `executeAsModal()` and run multiple times. You will notice how command ID toggles between two values every run. Also running in execModal negative commands does not work.

This is very counter intuitive - shouldn’t state changing actions be run in a modal state? Now it’s reverse - command (which changes Ps state, because this plugin command I run, generates a bunch of new layers) works only if it’s ran not in a modal state 😕 I’m very confused

I’m thinking if the issue could be because of _incompatibility_ of modal states between plugins 😕 I mean if Plugin1 runs a command of Plugin2 in `execModal()`, where Plugin2 also runs that command in its own `execModal()` 😕 In such case now we cannot group multiple commands into a single history state
