fix: preserve admin view on language change

This commit is contained in:
3252a8
2026-05-28 09:54:27 +03:00
parent 6c0d2932c3
commit 12e60629fe
3 changed files with 105 additions and 28 deletions
+12 -3
View File
@@ -211,8 +211,13 @@
const normalizeSection = (value) => ((VALID_SECTIONS || []).includes(value) ? value : "stats");
let active = normalizeSection(initialSection);
$: if (initialSection) {
active = normalizeSection(initialSection);
let lastInitialSection = active;
$: {
const nextInitialSection = normalizeSection(initialSection);
if (nextInitialSection !== lastInitialSection) {
active = nextInitialSection;
lastInitialSection = nextInitialSection;
}
}
let sidebarOpen = false;
let isCompact = false;
@@ -287,6 +292,10 @@
onSectionChange(next);
}
function changeLanguage(value) {
onLanguageChange(value, { section: "admin", adminSection: active });
}
function readSectionFromPath() {
if (typeof window === "undefined") return "stats";
const match = window.location.pathname.match(/^\/admin\/([a-z0-9_-]+)(?:\/.*)?$/i);
@@ -584,7 +593,7 @@
items={languageOptions}
disabled={languageBusy}
onOpenChange={setAdminLanguageMenuOpen}
onValueChange={onLanguageChange}
onValueChange={changeLanguage}
>
<Select.Trigger
class="admin-language-trigger"