I experienced this drawback. For some unjustified reason, I put a return statement in the onReady event handler of a page. Usually, that does not cause any issue in Preview.
By exception, if the return-ed function is a lightbox open statement (wixWindow.openLightbox), or is a promise and its .then() method includes a lightbox open statement, there are the conditions because Preview stalls out.
Preview stalling causes Editor almost completely blocked, and Editor page refresh is required.
Removing the useless return statement from onReady(), everything is OK.
Is this a Preview issue or is there something that I should know reading a good article?
Tks for advise
//sandbox
import wixWindow from 'wix-window';
/*
$w.onReady(function () {
wixWindow.openLightbox( "Test Lightbox", {} ) // <--- no problem this way
});
*/
/*
$w.onReady(function () {
wixWindow.openLightbox( "Test Lightbox", {} ) // <--- no problem this way
.then( () => {
console.log("Everything OK");
})
});
*/
/*
$w.onReady(function () {
return wixWindow.openLightbox( "Test Lightbox", {} ) // <--- Preview stalls out this way
.then( ( results ) => {
console.log("Everything OK: ", results);
return results;
})
.catch( (err) => {
console.log(err);
});
});
*/
/*
$w.onReady(function () {
testPromiseIncludingLightbox() // <--- no problem this way
.then( ( answer ) => {
console.log(answer);
})
});
function testPromiseIncludingLightbox() {
return wixWindow.openLightbox( "Test Lightbox", {} )
.then( ( results ) => {
console.log(results);
return results;
})
}
*/
$w.onReady(function () {
return testPromiseIncludingLightbox() // <--- Preview stalls out this way
.then( ( answer ) => {
console.log("Answer: ", answer);
})
});
function testPromiseIncludingLightbox() {
return wixWindow.openLightbox( "Test Lightbox", {} )
.then( ( results ) => {
console.log("Everything OK: ", results);
return results;
})
}
/*
$w.onReady(function () {
return testGenericPromise() // <--- no problem this way
.then( ( answer ) => {
console.log("Answer: ", answer);
})
});
function testGenericPromise() {
return new Promise(
function(resolve) {
setTimeout(resolve, 1);
}
);
}
*/