How to check if popup is already opened

Hello,

I am opening popup on enter key event on input field.

Problem is that when popup will be opened and user continue to press enter its always opens and opens new popup windows one over another.

Is there setting that allow only 1 instance to be opened?

In popup settings i see only Prevent scrolling the page when dialog is open, but i dont see preventing more than one instance.

I can do it with boolean variable for every popup, but i have allot of popups and some are called from multiple places so possibility to miss something is huge.

One boolean variable that will be for all popups is not good solution because there is some popups that opens after click in already opened popup, so if first make variable false, next will not popup.

If i make it with number variable and change it with separate number for every popup will also make problem because if popup number 1 is opened and from this popup you open popup 2, variable will be changed to 2, so after that you will be able to open new popup instance from popup number 1.

Best will be if there is some setting for this for not opening more than 1 instance of popup that is already opened. But as i see there is no option for this.

Anybody help?

Thank you in advance

Hey Zoran, great question!

I think this could be a nice approach for your use case: https://www.tella.tv/video/limit-popup-instance-366w

Can you take a look and let me know if that works for you?

Hello Joyce,

Thank you for you answer. And for making example and record the video.

Your package of boolean and name(or popup number) is great. I believed that still can be problem in this situation:

If i have oepened Popup Number 1 and from this popup i am opening another different Popup Number 2, when i will close Popup Number 2 it will reset openPopup variable, which mean after that you will be able again to open Popup Number 1 while he is already opened, just because variable openPopup was reseted from Popup Number 2.

But good news are that i just make some test with 2 popups and when you start interacting with opened Popup 1(click on Popup 1 button for opening Popup 2 or whatever), you are not interacting with page in background anymore and with this presing Enter will not open new Popup 1 instance. Which is good.

Before you click on opened popup you are still interacting with page in backgroun but now this will be solved with varaible till user click somewhere on popup, after that is not matter anymore.

Thank you very much

I also hope that for this problem will be also some solution because it is much more important for me and i believe for others in the future.