Lightbox not closing via main code

Question:
[Lightbox will not close via code once opened..]

Product:
[ Velo ,wix editorX.]

What are you trying to achieve:
[ simply close the light box via code once opened not with a user click element input]

What have you already tried:
import wixWindow from ‘wix-window’;

$w.onReady(function () {
// Open the lightbox
wixWindow.openLightbox(‘Promo’);

// Set a timeout to close the lightbox after 3 seconds
setTimeout(function() {
    wixWindow.lightbox.close();
}, 3000); // 3000 milliseconds = 3 seconds

});

Additional information:
[ The lightbox displays but will not close via program code. Settings in lightbox on and off seem to have no effect on the outcome. Only closing with button triggers from the lightbox works. I need to do it from the main code. For clarity, I am not trying to close it with any click element from within the code. I assumed that wixWindow.lightbox.close(); would simply close the box if open from the main code. I have tried passing data to to use code and close the lightbox within it directly, but that fails too, giving no error trap. I have tried different browsers Edge by default and Safari and Chrome all do the same in out of editor
Any help would be appreciated .Thank you.

example standard lightbox ‘Promo’ with this code does not close. …Home | My Site (myminxsite.editorx.io)

try

import {lightbox} from 'wix-window';

$w.onReady(function () {
    setTimeout(function(){ 
        lightbox.close();
    }, 3000);
});

Thank you for trying to help, it did not close the Lightbox, only importing that specific part of the module.

The following code works and has been tested…


import wixWindow from 'wix-window';

$w.onReady(function () {
// Open the lightbox
	setTimeout(function() {
		wixWindow.openLightbox('myLightbox');
	}, 3000); // 3000 milliseconds = 3 seconds

	// Set a timeout to close the lightbox after 3 seconds
	setTimeout(function() {
		wixWindow.lightbox.close();
	}, 6000); // 3000 milliseconds = 3 seconds
});

This code does not close programmatically for me in three different browsers, even though I’ve copied and pasted it exactly. I’ve even renamed ‘Fumble Field’ to ‘myLightbox’ to match the code exactly. Increasing }, 6000); to 6 seconds just delayed the exit but never actually closed it, just as before. Can I just check if you have triggers set to close by a button or user interaction, or any other code in myLightbox itself? Are you running it in the editor ? There isn’t much room for error, as the code should be straightforward. It’s very frustrating. Thanks again.

example standard lightbox with this code does not close. …Home | My Site (myminxsite.editorx.io)

Ok, maybe i did not pay 100% attention on …

2023-12-15 19_04_02-Lightbox not closing via main code - Discussion _ Ask a question - Wix Studio Co

So you are using Editor-X. I did my testing on ordinary one.

However, now i did the same on Editor-X and found further strange behaviour.

SETUP:

  1. Editor-X
  2. Ordinary Lightbox (nothing else)
  3. No buttons
  4. Working code (inside LIGHTBOX)
import wixWindow from 'wix-window';

$w.onReady(function () {
// Open the lightbox
	setTimeout(function() {
		wixWindow.openLightbox('myLightbox');
	}, 3000); // 3000 milliseconds = 3 seconds

	// Set a timeout to close the lightbox after 3 seconds
	setTimeout(function() {
		wixWindow.lightbox.close();
	}, 10000); // 3000 milliseconds = 3 seconds
});
  1. And the most important setting →

    Automatic displaying of the LIGHTBOX → (YES or NO)
    a) If you activate the automatic LIGHBOX-POP-UP → The lightbox do show
    b) If you deactivate the auto-POP-UP → The lightbox will never show, even controlled by code. It will never pop-up.

However → the CLOSE-Function do still work, if you have the auto-POP-UP setted to → ON.

Example can be seen here… (in this example the auto-pop-up is set to YES and after 10sec. the LIGHBOX will close.
https://russian-dima.editorx.io/examples/blank

At least the CLOSE-FUNCTION works.

@Wix
b) If you deactivate the auto-POP-UP → The lightbox will never show, even controlled by code. It will never pop-up.

WHY ???