From b5dfc02844e4dd20f0cb3d40a393bc8e23fa9d56 Mon Sep 17 00:00:00 2001 From: sahil839 Date: Thu, 1 Jul 2021 23:49:33 +0530 Subject: [PATCH] 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. --- static/js/hashchange.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/static/js/hashchange.js b/static/js/hashchange.js index 085e17b0e1..fa758d5f4a 100644 --- a/static/js/hashchange.js +++ b/static/js/hashchange.js @@ -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; }