amphtml
amphtml copied to clipboard
amp-lightbox closes without user interaction on Tab switch
We encountered a strange Bug with amp-lightbox closes automatically if the user switches Tabs in Chrome.

Reproducer
See Reproducer in AMP-Playground
If you click on the first slide, the lightbox opens. If you now go to another Tab in Chrome, and come back, the lightbox closes without user interaction. I traced it down to history-impl.js trying to pop the history in
if (toPop.length > 0) {
for (let i = 0; i < toPop.length; i++) {
// With the same delay timeouts must observe the order, although
// there's no hard requirement in this case to follow the pop order.
this.timer_.delay(() => toPop[i](historyState), 1);
}
}
and eventually calling this code in amp-lightbox-0.1.js:
F(a.getAmpDoc(), "history").push(function() {
return a.close(c)
}).then(function(U) {
a.ca = U
});
Checked mutations of test code
This does NOT happen, if I:
- remove the
amp-carousels - change the "close lightbox" link to a
button - remove the "close lightbox" link
- remove the
on="tap:my-lightbox.close"attribute on the link
Wild Guess
As this only happens if there is a link inside the lightbox that closes it, I think that is the culprit.
Workaround
For anyone who is affected by this bug right now: Change the "Close Lightbox" Link to a button..
Related Bugs
Probably #17442 is related.
Affected AMP Version
At least 2012301722001, but I've seen it earlier..
Affected Browsers
Tested in Chrome 87.0.4280.141, but probably more Browsers are affected by this.
// cc @choumx (sorry) because of his investigation in #17442
Even though this looks similar to https://github.com/ampproject/amphtml/issues/32449, this is not fixed with the release of 2101230412006.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.