hashchange: Fix update_browser_history() call for settings.

Even prior to my recent change in settings_panel_menu.js,
we were assigning window.location.hash a value that doesn't
have a '#' prefix.  This probably doesn't matter too much
for the browser, but it does confuse our own checks about
whether we're redundantly updating browser history.

Now we prefix the settings hash with '#' and we encorce
this convention with a blueslip error.
This commit is contained in:
Steve Howell
2018-12-03 16:57:48 +00:00
committed by Tim Abbott
parent 05be16e051
commit 779ed37cfa
2 changed files with 6 additions and 1 deletions

View File

@@ -272,6 +272,11 @@ function hashchanged_overlay(old_hash) {
exports.update_browser_history = function (new_hash) {
var old_hash = window.location.hash;
if (!new_hash.startsWith('#')) {
blueslip.error('programming error: prefix hashes with #: ' + new_hash);
return;
}
if (old_hash === new_hash) {
// If somebody is calling us with the same hash we already have, it's
// probably harmless, and we just ignore it. But it could be a symptom

View File

@@ -69,7 +69,7 @@ exports.make_menu = function (opts) {
curr_li.addClass("active");
curr_li.prev().addClass("no-border");
var settings_section_hash = hash_prefix + section;
var settings_section_hash = '#' + hash_prefix + section;
hashchange.update_browser_history(settings_section_hash);
$(".settings-section, .settings-wrapper").removeClass("show");