amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

browser history forward does not open the lightbox

Open ericfs opened this issue 11 years ago • 6 comments

Tested with the lightbox on /examples/everything.amp.html

Steps: Click on the "Responsive (w/srcset, w/lightbox)" image Close the lightbox by either clicking using the browser back button Note that there is now a forward history entry Navigating forward does nothing

ericfs avatar Sep 25 '15 20:09 ericfs

It shouldn't. At least it's not clear that it should. In case of the viewer and switching between articles - we are best not closing the lightbox at all. But that's also arguable.

Do you think it should open it again?

dvoytenko avatar Sep 26 '15 01:09 dvoytenko

I'm not sure if there is a normal behavior for modal lightboxes like this, but it leaves an entry in the forward history stack so feels a little confusing that you can navigate forwards but nothing changes.

ericfs avatar Sep 26 '15 02:09 ericfs

Ok. I think it means we also may need to add "historyPushed" state? I initially envisioned "historyPopped" only for popping. I know in History API it's the same event for both, so we can explore doing the same - but it's definitely counterintuitive and hard to support. I.e. one always knows how to go back, but not always how to go forward.

dvoytenko avatar Sep 26 '15 02:09 dvoytenko

With my current implementation the viewer is listening for all popstate events from the browser and sending them on to the AMP doc via "historyPopped" whenever this changes the stack value. So this could be from a forward or backward navigation. From the viewer side, this is simpler than trying to figure out if it is forward or backward.

Also, thinking about it more, I don't think that navigating forward probably doesn't happen very often compared to navigating back so this probably isn't a big deal. This behavior was surprising to me when I noticed it, but from the perspective of the Viewer, I don't know that it matters.

ericfs avatar Sep 26 '15 12:09 ericfs

It's definitely rare. Especially on the mobile where "forward" button is typically buried somewhere. I guess, yes, let's assume that historyPopped will be sent for all types of popstate events. I somewhat dislike that name, but it's better to be consistent with the existing API.

dvoytenko avatar Sep 27 '15 04:09 dvoytenko

I will close this issue for now then.

dvoytenko avatar Sep 27 '15 04:09 dvoytenko