FIX: Restore stream position in safari (#9993)
Safari uses an aggressive back/forward cache, which means the app loads very quickly when hitting Back. But, in topics with > 30 posts, hitting Back runs post stream calculations too early, which means that users get taken back to an earlier point in the stream, consistently. Using `onpageshow`, we can restore the correct location before the post stream calculations take place.
This commit is contained in:
parent
052c91770f
commit
bdba17cdf7
|
@ -333,6 +333,13 @@ export default MountWidget.extend({
|
|||
});
|
||||
|
||||
this.appEvents.on("post-stream:refresh", this, "_refresh");
|
||||
|
||||
// restore scroll position on browsers with aggressive BFCaches (like Safari)
|
||||
window.onpageshow = function(event) {
|
||||
if (event.persisted) {
|
||||
DiscourseURL.routeTo(this.location.pathname);
|
||||
}
|
||||
};
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
|
|
Loading…
Reference in New Issue