Improved showPanel() Flow

Currently the only way I could find to open a UXP panel from another UXP panel is like this:

const uxp = require("uxp");
const plugin = Array.from(uxp.pluginManager.plugins).pop();
await plugin.showPanel(id);

Firstly this is mostly undocumented, and secondly this syntax is just overcomplicated and doesn’t make much sense.

If we could have a more straightforward way to open a panel directly like:

uxp.pluginManager.showPanel(id);

Or if the request has to come from our active panel, then something like:

uxp.pluginManager.currentPanel.showPanel(id)

That would be a lot more straightforward and similar to how we would open panels in CEP.

Thanks!

I’m also banging my head and I can’t find any effective solutions, I tried with the panel ID but after restarting the PC it doesn’t work anymore, Is your code stable and does it open the chosen panel even after restarting the PC?

It’s even easier to put the name of the panel to open it.

Seems to work after a restart for me, not saying it’s a great solution but the only one I could find so far.

Turns out you need requiredPermissions.ipc.enablePluginCommunication enabled in your manifest for this to work:

"requiredPermissions": {
    "ipc": {
      "enablePluginCommunication": true
    },
},
1 Like

Also found a more reliable method for doing this since the secondary panel must be triggered from the main panel, you have to find it in the array of panels and it’s not always the last one so .pop() doesn’t work all the time:

export const openUXPPanel = async (id: string) => {
  const uxp = require("uxp") as typeof import("uxp");
  const plugins = Array.from(uxp.pluginManager.plugins);

  const plugin = plugins.find(
    (plugin) => plugin.id === uxp.entrypoints._pluginInfo.id
  );
  console.log("plugin", plugin, "opening panel: ", id);
  if (plugin) await plugin.showPanel(id);
  else console.error("No plugin found");
};

And make sure you still have ipc enabled in your manifest:

"requiredPermissions": {
    "ipc": {
      "enablePluginCommunication": true
    },
},
1 Like

It’s reliable until Adobe decides to change the uxp.entrypoints._pluginInfo. Any property starting in underscore is internal and should not be used by 3rd party. Most likely it’s here to stay, but you’ve been warned :smiley: I think I use it too in one of my plugins :sweat_smile:

Yep, but it’s all we’ve got

This function has been added to the lib functions where we’ll be adding other useful UXP functions in our new boilerplate Bolt UXP

1 Like