Work with popups pragrammatically?

Is there a way to control/check popups?

Tried to use AI to create a workflow with the logic of “back/close” logic:

  1. If any popups are opened, close the most recent.
  2. If no popups, navigate back.
  3. If no back, navigate to specified page.

It created a workflow with fake functions:

/* Get the popup stack safely using optional chaining */

const popupStack = wwLib?.wwPopups?.popupStack || [];
/* Return true if there are any popups in the stack */
return popupStack.length > 0;

to determine if we have a popups in stark and

const popupStack = wwLib.wwPopups.getPopupStack();
const mostRecentPopup = popupStack[popupStack.length - 1];
wwLib.wwPopups.close(mostRecentPopup.id);

to close the most recent triggering all “wait for close” workflows.

Sadly (and obviously) those functions and props don’t exist, so WF is not working.

How could I implement the behavior I mentioned above?

2 Likes

Hi Anton :waving_hand:

This looks like an interesting challenge.

I’m not sure you can close them programatically.

What is the use case? Why would you want more than 1 popup open?

1 Like

I use drawers (aka side-panels), like Notion-style, and from one drawer another can be opened. Like I can open task details from user’s card and then open observer’s user card from the task.

My particular case is I have an integrated app where I want to control a “back” button behavior. To do this, I need to know if we have popup opened, their order in a stack, and be able to address them to close or pop them higher.

Super cool Anton!

I don’t have an answer for you, but do keep us posted on what you learn about this functionality :folded_hands: