From 8c50abe2212d8f6154b0965ed83e414d459dcbe6 Mon Sep 17 00:00:00 2001 From: Linus Rath <139418639+rathlinus@users.noreply.github.com> Date: Mon, 4 May 2026 12:31:51 +0200 Subject: [PATCH] fix: synchronize mobile submenu view with browser history for better navigation --- app/[locale]/settings/page.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/[locale]/settings/page.tsx b/app/[locale]/settings/page.tsx index eeda92b8..543c3b24 100644 --- a/app/[locale]/settings/page.tsx +++ b/app/[locale]/settings/page.tsx @@ -213,6 +213,22 @@ export default function SettingsPage() { } }, [initialCheckDone, isAuthenticated, authLoading]); + // Sync the mobile submenu view with browser history so the system back + // button (or gesture) returns to the settings list before exiting /settings. + useEffect(() => { + if (isDesktop) return; + if (typeof window === 'undefined') return; + if (!mobileShowContent) return; + + window.history.pushState({ __settingsSubmenu: true }, ''); + + const handlePop = () => { + setMobileShowContent(false); + }; + window.addEventListener('popstate', handlePop); + return () => window.removeEventListener('popstate', handlePop); + }, [isDesktop, mobileShowContent]); + if (!isAuthenticated) { return null; } @@ -321,7 +337,7 @@ export default function SettingsPage() {