# Work with popups pragrammatically?

**URL:** <https://community.weweb.io/t/work-with-popups-pragrammatically/20086>\
**Category:** How do I?\
**Created:** [October 1, 2025, 4:21pm UTC](https://community.weweb.io/t/work-with-popups-pragrammatically/20086 "2025-10-01T16:21:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Antiokh](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/antiokh/32/2794_2.png) [@Antiokh](https://community.weweb.io/u/Antiokh)\
**Post date:** [October 1, 2025, 4:21pm UTC](https://community.weweb.io/t/work-with-popups-pragrammatically/20086/1 "2025-10-01T16:21:51Z")

</div>

### 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:

```auto
/* 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

```auto
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?

---

<div class="post-metadata">

**Author:** ![Agustin\_Carozo](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/agustin_carozo/32/13231_2.png) [@Agustin\_Carozo](https://community.weweb.io/u/Agustin_Carozo)\
**Post date:** [October 2, 2025, 2:34pm UTC](https://community.weweb.io/t/work-with-popups-pragrammatically/20086/2 "2025-10-02T14:34:01Z")

</div>

Hi Anton 👋

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?

---

<div class="post-metadata">

**Author:** ![Antiokh](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/antiokh/32/2794_2.png) [@Antiokh](https://community.weweb.io/u/Antiokh)\
**Post date:** [October 7, 2025, 11:29pm UTC](https://community.weweb.io/t/work-with-popups-pragrammatically/20086/3 "2025-10-07T23:29:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Antiokh](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/antiokh/32/2794_2.png) [@Antiokh](https://community.weweb.io/u/Antiokh)\
**Post date:** [October 8, 2025, 1:55pm UTC](https://community.weweb.io/t/work-with-popups-pragrammatically/20086/4 "2025-10-08T13:55:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Agustin\_Carozo](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/agustin_carozo/32/13231_2.png) [@Agustin\_Carozo](https://community.weweb.io/u/Agustin_Carozo)\
**Post date:** [October 8, 2025, 6:15pm UTC](https://community.weweb.io/t/work-with-popups-pragrammatically/20086/5 "2025-10-08T18:15:09Z")

</div>

Super cool Anton!

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