fix: preserve admin view on language change
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user