AMP Next Page creates an unnecessary history
What's the issue?
When navigation through pages, or to a page with amp-next-page enabled, the browser will create an extra history page for the exact page you are on.
This is frustrating when we are trying to utilise this feature on a news site, requiring multiple back clicks to return to the page you were previously on.
How do we reproduce the issue?
This can be seen live on the amp official documentation and any other page with amp-next-page enabled. Go to the below link and then confirm that history pages are exactly the same as the page you are on.
https://playground.amp.dev/?url=https%3A%2F%2Fpreview.amp.dev%2Fdocumentation%2Fexamples%2Fcomponents%2Famp-next-page&format=websites
What browsers are affected?
Notably Firefox and Chrome
Which AMP version is affected?
Using newest version of AMP
Thanks for reporting this issue @gavingrv. However, I am not able to repro. Can you please elaborate the steps to repro on playground, specifically "..confirm that history pages are exactly the same as the page you are on"?
FYI to repro I created a sample page with amp-next-page in the examples folder and accessing on localhost by running gulp.
Hi @dmanek
Whilst navigating through a website which has amp-next-page enabled, if you hit a page with it on - and then click back, the first history item created is the page that you are on - so the back button is redundant.
This is a link to a website with it on - if you navigate to any article, then use the back button - you will see that the initial click does nothing. example
@gavingrv When I tried to reproduce, this is what I saw, can you provide additional details?
https://user-images.githubusercontent.com/506183/104237619-2e1ea380-540d-11eb-9164-a72d5014e8c3.mp4
@dmanek That is the sort of experience I would expect, however if you see attached video you can see what I am experiencing.
It seems to create a new page history every time the page is loaded.
https://user-images.githubusercontent.com/77000861/104293662-26ffa000-54b6-11eb-9f17-8d0e220c4c54.mp4
@gavingrv thanks for the screencast. So IIUC your main issue is that duplicate history entires are being added upon reloading the page with amp-next-page, right?
Hi @dmanek
No - the issue is that if I navigate to an article, then click back, the initial back click doesn't do anything - I believe that it caused by the fact that amp-next-page creates a history item each time the page loads. So the issues go hand in hand with each other.
I hope that makes sense.
Hi @gavingrv, I was looking into this recently (as part of fixing #33404), but I'm not able to repro. Can you please re-verify or include detailed steps to repro? Ideally, a jsbin/glitch where this issue is consistently reproducible would be great! Thanks.
Hi @dmanek - The issue is even evident on the amp.dev documentation.
Take the following 2 examples: https://amp.dev/documentation/examples/components/amp-facebook/?format=websites https://amp.dev/documentation/examples/components/amp-next-page/?format=websites
After you click the 'Open in Playground' button on both examples, then click the back button on your browser (without doing anything else on the page), the amp-next-page takes more clicks than the Facebook component.
I hope that makes sense.
Hi @gavingrv yes, I could finally reproduce this consistently in Firefox. I created an isolated test page here: https://mulberry-peach-schooner.glitch.me/
Upon further investigation, realized that this issue is caused by the fix for #25553. @wassgha can you provide some context or use cases behind this? cc @nainar in case you recollect anything.