From c5ac75ce60d3a3b329bc983d29c31e07e057023e Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Tue, 21 Nov 2023 23:21:51 +0530 Subject: [PATCH] user_groups: Reset right panel on changing toggle. We now reset right panel when toggling from "All groups" to "Your groups" if the group opened in right section is not present in the "Your groups" list, i.e. user is not a member of that group. --- web/src/user_group_edit.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/web/src/user_group_edit.js b/web/src/user_group_edit.js index a2d57fe71b..91acd8cb76 100644 --- a/web/src/user_group_edit.js +++ b/web/src/user_group_edit.js @@ -558,6 +558,7 @@ function redraw_left_panel(tab_name) { groups_list_data.sort(compare_by_name); group_list_widget.replace_list_data(groups_list_data); update_empty_left_panel_message(); + maybe_reset_right_panel(groups_list_data); } export function redraw_user_group_list() { @@ -594,6 +595,20 @@ export function add_or_remove_from_group(group) { } } +export function maybe_reset_right_panel(groups_list_data) { + if (active_group_id === undefined) { + return; + } + + const group_ids = new Set(groups_list_data.map((group) => group.id)); + if (!group_ids.has(active_group_id)) { + $(".right .settings").hide(); + $(".nothing-selected").show(); + $(".group-row.active").removeClass("active"); + reset_active_group_id(); + } +} + export function update_empty_left_panel_message() { // Check if we have any groups in panel to decide whether to // display a notice.