"use client"; import { useRef, type ReactNode } from "react"; import { IconChevronDown, IconFolderOpen, IconLoader2 } from "@tabler/icons-react"; import { useTranslation } from "react-i18next"; import { Button } from "@kandev/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@kandev/ui/dropdown-menu"; import { useTaskFolderAction } from "@/hooks/use-task-folder-action"; import { TaskFolderPicker } from "./task-folder-picker"; export function EditorActionsDropdown({ sessionId, children, }: { sessionId: string | null; children: ReactNode; }) { const { t } = useTranslation(); const action = useTaskFolderAction(sessionId); const triggerRef = useRef(null); const selectedSessionRef = useRef(null); return ( <> { const selectedSession = selectedSessionRef.current; selectedSessionRef.current = null; if (!selectedSession || selectedSession !== sessionId) return; event.preventDefault(); triggerRef.current?.focus(); action.open(triggerRef.current ?? undefined); }} > {children} { selectedSessionRef.current = sessionId; }} > {action.isLoading ? ( ) : ( )} {t("editors:openFolder")} {action.isLoading ? t("editors:openingFolder") : ""} ); }