deer-flow/frontend/src/components/workspace/workspace-sidebar-trigger.tsx
ShallAbby c11ba84708
fix(frontend): keep collapsed sidebar navigation visible on mobile (#7198)
* fix(frontend): keep collapsed sidebar navigation visible on mobile

* fix(frontend): address mobile sidebar review feedback

* fix(ci): keep frontend agent guidance within size budget

* fix(frontend): align mobile sidebar focus and trigger state

* fix(frontend): keep Agents header actions within mobile viewport

---------

Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
2026-10-22 15:13:01 +08:00

41 lines
1.2 KiB
TypeScript

"use client";
import { PanelLeftCloseIcon, PanelLeftOpenIcon } from "lucide-react";
import { Button } from "@/components/ui/button";
import { useSidebar } from "@/components/ui/sidebar";
import { cn } from "@/lib/utils";
export function WorkspaceSidebarTrigger({
className,
onClick,
...props
}: React.ComponentProps<typeof Button>) {
const { isMobile, open, openMobile, toggleSidebar } = useSidebar();
const expanded = isMobile ? openMobile : open;
return (
<Button
type="button"
data-sidebar="trigger"
data-slot="sidebar-trigger"
variant="ghost"
size="icon"
className={cn("size-7 opacity-50 hover:opacity-100", className)}
{...props}
aria-expanded={expanded}
aria-haspopup={isMobile ? "dialog" : undefined}
onClick={(event) => {
onClick?.(event);
if (event.defaultPrevented) return;
// Touch browsers need an explicit focus target for drawer dismissal.
if (isMobile && !openMobile) event.currentTarget.focus();
toggleSidebar();
}}
>
{expanded ? <PanelLeftCloseIcon /> : <PanelLeftOpenIcon />}
<span className="sr-only">Toggle Sidebar</span>
</Button>
);
}