settings: Show correct section when increasing screen width.

Currently if the settings overlay is opened on narrow screen,
where only left side panels are shown, and then the screen
width is increased, the right side shows "Profile" and
"Account and privacy" sections of personal settings together
everytime.

This fixes it to show the last opened section or the first
section or the section used in url.
This commit is contained in:
Sahil Batra 2024-07-31 19:25:08 +05:30 committed by Tim Abbott
parent d7889221db
commit 8fd5c02916
3 changed files with 10 additions and 10 deletions

View File

@ -93,10 +93,8 @@ export class SettingsPanelMenu {
const section = this.current_tab;
const user_settings_tab = this.current_user_settings_tab;
if (two_column_mode()) {
// In one column mode want to show the settings list, not the first settings section.
this.activate_section_or_default(section, user_settings_tab);
}
const activate_section_for_mobile = two_column_mode();
this.activate_section_or_default(section, user_settings_tab, activate_section_for_mobile);
this.$curr_li.trigger("focus");
}
@ -167,7 +165,7 @@ export class SettingsPanelMenu {
this.current_user_settings_tab = tab;
}
activate_section_or_default(section, user_settings_tab) {
activate_section_or_default(section, user_settings_tab, activate_section_for_mobile = true) {
popovers.hide_all();
if (!section) {
// No section is given so we display the default.
@ -215,9 +213,11 @@ export class SettingsPanelMenu {
scroll_util.reset_scrollbar($("#settings_content"));
const $settings_overlay_container = $("#settings_overlay_container");
$settings_overlay_container.find(".right").addClass("show");
$settings_overlay_container.find(".settings-header.mobile").addClass("slide-left");
if (activate_section_for_mobile) {
const $settings_overlay_container = $("#settings_overlay_container");
$settings_overlay_container.find(".right").addClass("show");
$settings_overlay_container.find(".settings-header.mobile").addClass("slide-left");
}
set_settings_header(section);
}

View File

@ -1,4 +1,4 @@
<div id="account-settings" class="settings-section show" data-name="account-and-privacy">
<div id="account-settings" class="settings-section" data-name="account-and-privacy">
<div class="alert" id="dev-account-settings-status"></div>
<div class="account-settings-form">
<div class="inline-block">

View File

@ -1,4 +1,4 @@
<div id="profile-settings" class="settings-section show" data-name="profile">
<div id="profile-settings" class="settings-section" data-name="profile">
<div class="profile-settings-form">
<div class="profile-main-panel inline-block">
<h3 class="inline-block" id="user-profile-header">{{t "Profile" }}</h3>