hashchange: Fix bug when directly chaning hash in settings overlay.

Reproducer:
* Open the settings overlay from gear menu, the profile (user profile
not organization profile) is opened.
* Note the current hash in browser is "#settings/profile".
* Now directly change the hash to be "#organization/organization-permissions".

You will notice that the content is fine, but there is problem in left
sidebar and the hash. The left sidebar content is still of user
settings and not organization settings and the hash in the browser is
"#settings/organization-permissions".

Now the bug was due to normal_settings.activate_section_or_default
call instead of org_settings.activate_section_or_default.
Calling from normal_settings leads to hash_prefix being "#settings"
which changes the hash in the browser and also toggles the left
sidebar to display settings part instead of organization. The right
section content is of organization-permissions only because it
depends only on section and not prefix.

So, this commit adds a if-else condition deciding what to call based
on the hash.
This commit is contained in:
sahil839 2021-07-01 23:49:33 +05:30 committed by Tim Abbott
parent ce2821bc28
commit b5dfc02844

View File

@ -243,7 +243,11 @@ function do_hashchange_overlay(old_hash) {
settings_hashes.has(base) && settings_hashes.has(old_base) && overlays.settings_open();
if (is_hashchange_internal) {
settings_toggle.highlight_toggle(base);
settings_panel_menu.normal_settings.activate_section_or_default(section);
if (base === "settings") {
settings_panel_menu.normal_settings.activate_section_or_default(section);
} else {
settings_panel_menu.org_settings.activate_section_or_default(section);
}
return;
}