Navigating to a none existing / private page. Refresh will break back navigation


(lid) #1

###Reproduction

1.Go to a link that takes you no where (404) No where is here

2.Refresh the page F5

3.Try to hit the back button

##Result:
You are not going to be able to come back to this topic or any previous history.
the url will change but the page will stay as not exists

###Expected result:
Hitting the back button will take you back to the page you came from

###Proposed fix
Adding the following code to the error page, should allow the browser to preserve it back navigation.

window.onpopstate = function(event) {
  if (!window.hasOwnProperty("Discourse")){  //check if Discourse object exists if not take care of back navigation
    window.location = document.location
  }
};

(lid) #2

Oh well there is a different bug on the current version of discourse hitting a none existing page
Here you get a blank page. but you can still reproduce the same behavior on refresh

cc: @eviltrout


(Jeff Atwood) #3

Can you take a look at this tomorrow @eviltrout?


(Robin Ward) #4

Fixed the refreshTitle error here, thanks for letting me know:


(Robin Ward) #5

Your fix worked well, thanks!

https://github.com/discourse/discourse/commit/a967d4dfba292ee15f5a490e98495e35f27b1ffb


(Jeff Atwood) #6