Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Strange string format in flyout menu click handler

Community Expert ,
Sep 02, 2025 Sep 02, 2025

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

Bug Unresolved
TOPICS
CEP
296
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
2 Comments
Community Expert ,
Sep 04, 2025 Sep 04, 2025

@erinferinferinf can you share some insights on the above?

-Manan

Translate
Report
Community Expert ,
Sep 11, 2025 Sep 11, 2025
LATEST

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.

Translate
Report