@@ -8,10 +8,7 @@ import { usePathname } from "next/navigation";
88import { useCallback , useEffect , useMemo , useRef , useState } from "react" ;
99import { Button } from "@/components/ui/button" ;
1010import { ScrollArea } from "@/components/ui/scroll-area" ;
11- import {
12- useAccordionStates ,
13- usePersistentState ,
14- } from "@/hooks/use-persistent-state" ;
11+ import { useAccordionStates } from "@/hooks/use-persistent-state" ;
1512import { useWebsites } from "@/hooks/use-websites" ;
1613import { cn } from "@/lib/utils" ;
1714import { CategorySidebar } from "./category-sidebar" ;
@@ -37,9 +34,9 @@ type NavigationConfig = {
3734export function Sidebar ( ) {
3835 const pathname = usePathname ( ) ;
3936 const [ isMobileOpen , setIsMobileOpen ] = useState ( false ) ;
40- const [ selectedCategory , setSelectedCategory ] = usePersistentState <
37+ const [ selectedCategory , setSelectedCategory ] = useState <
4138 string | undefined
42- > ( "sidebar-selected-category" , undefined ) ;
39+ > ( undefined ) ;
4340 const { websites, isLoading : isLoadingWebsites } = useWebsites ( ) ;
4441 const accordionStates = useAccordionStates ( ) ;
4542 const sidebarRef = useRef < HTMLDivElement > ( null ) ;
@@ -151,6 +148,10 @@ export function Sidebar() {
151148 return ( ) => document . removeEventListener ( "keydown" , handleKeyDown ) ;
152149 } , [ isMobileOpen , closeSidebar ] ) ;
153150
151+ useEffect ( ( ) => {
152+ setSelectedCategory ( undefined ) ;
153+ } , [ pathname ] ) ;
154+
154155 useEffect ( ( ) => {
155156 if ( isMobileOpen && sidebarRef . current ) {
156157 const firstFocusableElement = sidebarRef . current . querySelector (
0 commit comments