Fix bug with statistics display on mobile

This commit is contained in:
Jack Kingsman
2026-02-16 23:01:04 -08:00
parent 3232075767
commit f490cc756f
2 changed files with 51 additions and 3 deletions
+10 -3
View File
@@ -102,6 +102,7 @@ export function SettingsModal(props: SettingsModalProps) {
};
const [isMobileLayout, setIsMobileLayout] = useState(getIsMobileLayout);
const externalDesktopSidebarMode = externalSidebarNav && !isMobileLayout;
const [expandedSections, setExpandedSections] = useState<Record<SettingsSection, boolean>>(() => {
const isMobile = getIsMobileLayout();
return {
@@ -245,8 +246,16 @@ export function SettingsModal(props: SettingsModalProps) {
setSectionError(null);
}, [externalSidebarNav, desktopSection]);
// On mobile with external sidebar nav, auto-expand the selected section
useEffect(() => {
if (!externalSidebarNav || !isMobileLayout || !desktopSection) return;
setExpandedSections((prev) =>
prev[desktopSection] ? prev : { ...prev, [desktopSection]: true }
);
}, [externalSidebarNav, isMobileLayout, desktopSection]);
// Fetch statistics when the section becomes visible
const statisticsVisible = externalSidebarNav
const statisticsVisible = externalDesktopSidebarMode
? desktopSection === 'statistics'
: expandedSections.statistics;
@@ -596,8 +605,6 @@ export function SettingsModal(props: SettingsModalProps) {
setSectionError(null);
};
const externalDesktopSidebarMode = externalSidebarNav && !isMobileLayout;
const isSectionVisible = (section: SettingsSection) =>
externalDesktopSidebarMode ? desktopSection === section : expandedSections[section];