Skip to content

Commit 0ece808

Browse files
committed
sidebar fixes
1 parent 2acc907 commit 0ece808

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/components/Sidebar.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import styled from 'styled-components'
2-
import { NavLink } from 'react-router-dom'
2+
import { NavLink, useLocation } from 'react-router-dom'
33
import { useState, useEffect } from 'react';
44

55
const SidebarContainer = styled.div<{ $isExpanded: boolean }>`
@@ -62,6 +62,7 @@ export const Sidebar = () => {
6262
const [focusedIndex, setFocusedIndex] = useState(-1);
6363
const [isExpanded, setIsExpanded] = useState(false);
6464
const [isMobile, setIsMobile] = useState(window.innerWidth < 768);
65+
const location = useLocation();
6566

6667
// Helper function to determine shortcut keys
6768
const determineShortcutKeys = (items: { to: string; label: string }[]): NavItemType[] => {
@@ -101,6 +102,8 @@ export const Sidebar = () => {
101102

102103
// Add mobile detection
103104
useEffect(() => {
105+
setFocusedIndex(baseNavItems.findIndex(item => item.to === location.pathname));
106+
104107
const handleResize = () => {
105108
setIsMobile(window.innerWidth < 768);
106109
if (window.innerWidth >= 768) {
@@ -148,7 +151,7 @@ export const Sidebar = () => {
148151

149152
const renderLabel = (label: string, shortcutKey: string) => {
150153
const index = label.toLowerCase().indexOf(shortcutKey);
151-
if (index === -1) return label;
154+
if (index === -1 || isMobile) return label;
152155

153156
return (
154157
<>

0 commit comments

Comments
 (0)