Skip to main content
Community Expert
September 2, 2025

Strange string format in flyout menu click handler

  • September 2, 2025
  • 2 replies
  • 223 views

I am adding a flyout menu to my CEP extension that is targetted to InDesign. The menu is added fine, i add the eventhandler to com.adobe.csxs.events.flyoutMenuClicked even as well. However, inside the event handler the data object that is supposed to contain the menuID and menuName has a strange string which seems like a JSON but is an invalid JSON. My code is as following

const flyoutMenu = `
    <Menu>
        <MenuItem Id="option1" Label="Autolayout" Enabled="true" Checked="false"/>
    </Menu>
`;
csi.setPanelFlyoutMenu(flyoutMenu);
csi.addEventListener("com.adobe.csxs.events.flyoutMenuClicked", function(event) {
    const clickedMenuId = event.data.menuId;

    switch (clickedMenuId) {
        case "option1":
            alert("Autolayout selected");
            break;
    }
});

When I check event.data in the console I get the following

"${"menuName"=2"Autolayout","menuId"=2"option1"}"

 Notice the $, =2 I am not sure wh

2 replies

Justin Taylor-Hyper Brew
Community Expert
Community Expert
September 11, 2025

Yea this is really weird. I noticed this a few years back, CEP 10 or 11 I think. On dev mode it's fine, it returns an object as expected, but on build it returns a messed up JSON string.

 

Here's my workaround in TS for Bolt CEP:

 

  interface FlyoutMenuEvent {
    data:
      | {
          menuId: string;
        }
      | string;
  }
  const flyoutHandler = (event: FlyoutMenuEvent) => {
    let menuId;
    if (typeof event.data === "string") {
      try {
        //? On build the events come in garbled string which requires some replacing and then parsing to get the data
        menuId = JSON.parse(
          event.data.replace(/\$/g, "").replace(/\=2/g, ":")
        ).menuId;
      } catch (e) {
        console.error(e);
      }
    } else {
      menuId = event.data.menuId;
    }
    if (menuId === "website") {
      // openLinkInBrowser(homePage);
    } else if (menuId === "info") {
      // openLinkInBrowser(productPage);
    } else if (menuId === "refresh") {
      location.reload();
    }
  };



Unlikely to get a fix as CEP development isn't getting updates anymore unless it's something really bad.

Community Expert
September 5, 2025

@erinferinferinf can you share some insights on the above?

-Manan

-Manan