Onlightboxes close

as the code above…

lightbox1 have a button to open lightbox2 that come back to lightbox1 at close…
when lightboxe1 close… “.then” is not working on the page…

if lightboxe1 close without go to lightbox2… the “.then” is working and do the rest on the page.

some solutions?
thanks to all.

page code :
                
wixWindow.openLightbox("lightbox1", data)
            .then(() => {
                (do somethings when it close)
                }
                
///////////////////////////////////////////////////////////////
               
lightbox1 code: 

on press button >> 
wixWindow.openLightbox("lightbox2", data)
            .then(() => {
                wixWindow.openLightbox("lightbox1", data)
                }
                
                

Opening the LB 2, close the 1st and the .then() (LB1) is done.
The openLB on LB2 needs a .then() as well.

thanks, but “then()” must be run the page, not in LB

“then()” is then chain on the promise that started it. “openLightbox” is a promise.
The Browser works async. JS keeps the promise on till gets resolved.
The issue is about Wix closing the LT1 on starting LT2 because only one LB can to be open.