Skip to content

Commit

Permalink
fix(front): fix problem with navigation focus not changing color afte…
Browse files Browse the repository at this point in the history
…r pressing `alt+->`

Fixed problem when location is moved by `alt+->` by `usePathname` to monitor the path
  • Loading branch information
SARDONYX-sard committed Oct 11, 2023
1 parent 658860b commit 330041f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions frontend/src/components/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import BottomNavigationAction from "@mui/material/BottomNavigationAction";
import TransformIcon from "@mui/icons-material/Transform";
import SettingsIcon from "@mui/icons-material/Settings";
import { styled } from "@mui/material";
import { useRouter } from "next/navigation";
import { useRouter, usePathname } from "next/navigation";

const Nav = styled(BottomNavigation)(() => {
return {
Expand All @@ -21,16 +21,16 @@ const Nav = styled(BottomNavigation)(() => {

export default function MenuNavigation() {
const router = useRouter();
const pathname = usePathname();
const [value, setValue] = useState(0);

useEffect(() => {
const location = window.location.pathname;
if (location === "/") {
if (pathname=== "/") {
setValue(0);
} else if (location === "/settings") {
} else if (pathname=== "/settings") {
setValue(1);
}
}, [setValue]);
}, [setValue, pathname]);

return (
<Nav
Expand Down

0 comments on commit 330041f

Please sign in to comment.