mirror of
https://github.com/docmost/docmost.git
synced 2025-11-12 19:22:39 +10:00
fix active settings path
This commit is contained in:
@ -9,7 +9,7 @@ import {
|
|||||||
IconUsersGroup,
|
IconUsersGroup,
|
||||||
IconSpaces,
|
IconSpaces,
|
||||||
} from "@tabler/icons-react";
|
} from "@tabler/icons-react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link, useLocation } from "react-router-dom";
|
||||||
import classes from "./settings.module.css";
|
import classes from "./settings.module.css";
|
||||||
|
|
||||||
interface DataItem {
|
interface DataItem {
|
||||||
@ -52,7 +52,8 @@ const groupedData: DataGroup[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export default function SettingsSidebar() {
|
export default function SettingsSidebar() {
|
||||||
const [active, setActive] = useState("Profile");
|
const pathname = useLocation().pathname;
|
||||||
|
const [active, setActive] = useState(pathname);
|
||||||
|
|
||||||
const menuItems = groupedData.map((group) => (
|
const menuItems = groupedData.map((group) => (
|
||||||
<div key={group.heading}>
|
<div key={group.heading}>
|
||||||
@ -62,11 +63,11 @@ export default function SettingsSidebar() {
|
|||||||
{group.items.map((item) => (
|
{group.items.map((item) => (
|
||||||
<Link
|
<Link
|
||||||
className={classes.link}
|
className={classes.link}
|
||||||
data-active={item.label === active || undefined}
|
data-active={active.startsWith(item.path) || undefined}
|
||||||
key={item.label}
|
key={item.label}
|
||||||
to={item.path}
|
to={item.path}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setActive(item.label);
|
setActive(item.path);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<item.icon className={classes.linkIcon} stroke={2} />
|
<item.icon className={classes.linkIcon} stroke={2} />
|
||||||
|
|||||||
Reference in New Issue
Block a user