diff options
Diffstat (limited to 'frontend/src/components/Sidebar/Sidebar.tsx')
| -rw-r--r-- | frontend/src/components/Sidebar/Sidebar.tsx | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/frontend/src/components/Sidebar/Sidebar.tsx b/frontend/src/components/Sidebar/Sidebar.tsx index 77e23a6..f280a59 100644 --- a/frontend/src/components/Sidebar/Sidebar.tsx +++ b/frontend/src/components/Sidebar/Sidebar.tsx | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | import React, { useCallback } from "react"; | 1 | import React, { useCallback, useRef } from "react"; |
| 2 | import { useLocation } from "react-router-dom"; | 2 | import { useLocation } from "react-router-dom"; |
| 3 | import { UserProfile } from "@customTypes/Profile"; | 3 | import { UserProfile } from "@customTypes/Profile"; |
| 4 | 4 | ||
| @@ -24,6 +24,8 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 24 | const [isSearching, setIsSearching] = React.useState<boolean>(false); | 24 | const [isSearching, setIsSearching] = React.useState<boolean>(false); |
| 25 | const [selectedButtonIndex, setSelectedButtonIndex] = React.useState<number>(1); | 25 | const [selectedButtonIndex, setSelectedButtonIndex] = React.useState<number>(1); |
| 26 | 26 | ||
| 27 | const searchbarRef = useRef<HTMLInputElement>(null); | ||
| 28 | |||
| 27 | const location = useLocation(); | 29 | const location = useLocation(); |
| 28 | const path = location.pathname; | 30 | const path = location.pathname; |
| 29 | 31 | ||
| @@ -34,6 +36,7 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 34 | if (clicked_sidebar_idx == 0 && !isSearching) { | 36 | if (clicked_sidebar_idx == 0 && !isSearching) { |
| 35 | if (!isSearching) { | 37 | if (!isSearching) { |
| 36 | setIsSearching(true); | 38 | setIsSearching(true); |
| 39 | searchbarRef.current?.focus(); | ||
| 37 | } | 40 | } |
| 38 | } else { | 41 | } else { |
| 39 | setIsSearching(false); | 42 | setIsSearching(false); |
| @@ -57,13 +60,13 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 57 | }, [path]); | 60 | }, [path]); |
| 58 | 61 | ||
| 59 | return ( | 62 | return ( |
| 60 | <div className={`h-screen w-80 not-md:w-full text-white bg-block flex flex-col not-md:flex-row not-md:bg-gradient-to-t not-md:from-block not-md:to-bright | 63 | <div className={`md:h-screen w-80 not-md:w-full text-white bg-block flex flex-col not-md:flex-row not-md:bg-gradient-to-t not-md:from-block not-md:to-bright |
| 61 | }`}> | 64 | }`}> |
| 62 | 65 | ||
| 63 | {/* Header */} | 66 | {/* Header */} |
| 64 | <_Header /> | 67 | <_Header /> |
| 65 | 68 | ||
| 66 | <div className="flex flex-1 overflow-hidden w-full not-md:hidden "> | 69 | <div className="flex flex-1 overflow-hidden w-full"> |
| 67 | <div className={`flex flex-col transition-all duration-300 ${isSearching ? "w-[64px]" : "w-full"}`}> | 70 | <div className={`flex flex-col transition-all duration-300 ${isSearching ? "w-[64px]" : "w-full"}`}> |
| 68 | {/* Sidebar Content */} | 71 | {/* Sidebar Content */} |
| 69 | <_Content isSearching={isSearching} selectedButtonIndex={selectedButtonIndex} handle_sidebar_click={handle_sidebar_click} /> | 72 | <_Content isSearching={isSearching} selectedButtonIndex={selectedButtonIndex} handle_sidebar_click={handle_sidebar_click} /> |
| @@ -73,7 +76,7 @@ const Sidebar: React.FC<SidebarProps> = ({ | |||
| 73 | </div> | 76 | </div> |
| 74 | 77 | ||
| 75 | <div className={`flex bg-panel ${isSearching ? 'w-full' : "w-0"}`}> | 78 | <div className={`flex bg-panel ${isSearching ? 'w-full' : "w-0"}`}> |
| 76 | <_Search profile={profile} /> | 79 | <_Search profile={profile} searchbarRef={searchbarRef} /> |
| 77 | </div> | 80 | </div> |
| 78 | 81 | ||
| 79 | </div> | 82 | </div> |