File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed
apps/dashboard/components/layout Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -158,9 +158,21 @@ export function Sidebar({ user }: SidebarProps) {
158158 return ( ) => document . removeEventListener ( "keydown" , handleKeyDown ) ;
159159 } , [ isMobileOpen , closeSidebar ] ) ;
160160
161+ const defaultCategory = useMemo (
162+ ( ) => getDefaultCategory ( pathname ) ,
163+ [ pathname ]
164+ ) ;
165+ const previousDefaultCategoryRef = useRef < string | undefined > ( undefined ) ;
166+
161167 useEffect ( ( ) => {
162- setSelectedCategory ( undefined ) ;
163- } , [ pathname ] ) ;
168+ if (
169+ previousDefaultCategoryRef . current !== undefined &&
170+ previousDefaultCategoryRef . current !== defaultCategory
171+ ) {
172+ setSelectedCategory ( undefined ) ;
173+ }
174+ previousDefaultCategoryRef . current = defaultCategory ;
175+ } , [ defaultCategory ] ) ;
164176
165177 useEffect ( ( ) => {
166178 if ( isMobileOpen && sidebarRef . current ) {
You can’t perform that action at this time.
0 commit comments