Dogstudio / highway

Highway - A Modern Javascript Transitions Manager
https://highway.js.org/
MIT License
1.43k stars 92 forks source link

History back during fetching causes page content / URL mismatch #41

Closed TristanPct closed 5 years ago

TristanPct commented 5 years ago

Hello,

I noticed that if I go back in my history during page fetching the URL change to the previous one but not the content, Highway shows the new content.

For example, if I go from page A to B everything is good, but then if I'm going to page C and click browser history back button during fetching, I see page B URL but page C content.

Anthodpnt commented 5 years ago

Hi @TristanPct,

Thanks for reporting this issue, let us take a look at it and come back to you ASAP.

Best regards, Anthony

joshkirk-zero commented 5 years ago

This is something that is really hard to account for. Popstate events are not cancellable, so if a user clicks forward or back during a transition you can't stop them.

TristanPct commented 5 years ago

Yes, but the expected behaviour would be to stop transition and restore previous content, without prevent user action.

joshkirk-zero commented 5 years ago

This is a difficult topic, but definitely worth exploring! We'd have to determine if a popstate event occurs, and if this.running is true, handle accordingly. I don't believe any other PJAX lib has solved for this, so it'd be cool to see a solution 👍

ThaoD5 commented 5 years ago

Hey @joshkirk-zero @TristanPct ,

Earlier last week I took some time to investigate this and couldn't achieve something correct, I indeed am playing with the this.running part and doing some conditions but so far I didn't manage to have a correct solution without it being somewhat buggy, maybe my head was a bit too much into it and didn't see the most straight forward solution haha

I will have a look again whenever I have some more time to find a solution to this :-)

Greetings,

Anthodpnt commented 5 years ago

Hey guys,

This kind of issue is inherent to the browser. I don't think we could come with a solid solution right now. I'll close the issue for now...

Thanks