Merge bug/settings-tab-persist: keep the selected Settings tab on reload
This commit is contained in:
commit
4759103f26
1 changed files with 13 additions and 1 deletions
|
|
@ -24,6 +24,14 @@ const TABS: { id: TabId; icon: typeof Monitor }[] = [
|
||||||
{ id: "account", icon: User },
|
{ id: "account", icon: User },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// Persist the active tab so a reload (F5) keeps the user where they were instead of
|
||||||
|
// snapping back to "appearance".
|
||||||
|
const SETTINGS_TAB_KEY = "siftlode.settingsTab";
|
||||||
|
function loadSettingsTab(): TabId {
|
||||||
|
const v = localStorage.getItem(SETTINGS_TAB_KEY);
|
||||||
|
return TABS.some((tabItem) => tabItem.id === v) ? (v as TabId) : "appearance";
|
||||||
|
}
|
||||||
|
|
||||||
// Settings as a page (Design B): rendered in the main content area, not an overlay. It keeps
|
// Settings as a page (Design B): rendered in the main content area, not an overlay. It keeps
|
||||||
// the frosted `.glass` surface so it still refracts the ambient backdrop. The page title is
|
// the frosted `.glass` surface so it still refracts the ambient backdrop. The page title is
|
||||||
// shown by the Header; the tab rail stays as in-page sub-navigation.
|
// shown by the Header; the tab rail stays as in-page sub-navigation.
|
||||||
|
|
@ -43,7 +51,11 @@ export default function SettingsPanel({
|
||||||
onOpenWizard: () => void;
|
onOpenWizard: () => void;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [tab, setTab] = useState<TabId>("appearance");
|
const [tab, setTabState] = useState<TabId>(loadSettingsTab);
|
||||||
|
const setTab = (id: TabId) => {
|
||||||
|
setTabState(id);
|
||||||
|
localStorage.setItem(SETTINGS_TAB_KEY, id);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="p-4 max-w-3xl w-full mx-auto">
|
<div className="p-4 max-w-3xl w-full mx-auto">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue