diff --git a/app/components/blocks/sidebar.tsx b/app/components/blocks/sidebar.tsx index b80f772..a685f11 100644 --- a/app/components/blocks/sidebar.tsx +++ b/app/components/blocks/sidebar.tsx @@ -13,7 +13,7 @@ import { ProfileDropdown } from "./profile-dropdown"; import { NavItem } from "../atoms/nav-item"; import { CollapsibleChild, CollapsibleItem } from "../atoms/collapsible-item"; import { navItems, secondaryNavItems } from "@/data/nav"; -import { FC, useState } from "react"; +import { FC, useRef, useState } from "react"; import { cn } from "@/lib/styles"; interface SidebarProps { @@ -26,6 +26,14 @@ const Sidebar: FC = ({ toggleSidebar, }) => { // TODO(glen): Move this to a separate file + const searchInputRef = useRef(null); + + const handleSearchIconClick = () => { + toggleSidebar(); // Maximize the sidebar + setTimeout(() => { + searchInputRef.current?.focus(); // Focus the search input after the sidebar is maximized + }, 0); + }; return (
@@ -55,7 +63,7 @@ const Sidebar: FC = ({ {minimalSidebar ? (
{/* TODO: automatically set focus to the search inpu field */} @@ -65,6 +73,7 @@ const Sidebar: FC = ({