π OpenHands: AI-Driven Development
chore(frontend): Close conversation card context menu when clicking elsewhere (#6111)
sp.wackd1555e093cce
diff --git a/frontend/src/components/features/conversation-panel/conversation-card-context-menu.tsx b/frontend/src/components/features/conversation-panel/conversation-card-context-menu.tsxnew file mode 100644index 0000000000..d2b290e000--- /dev/null+++ b/frontend/src/components/features/conversation-panel/conversation-card-context-menu.tsx@@ -0,0 +1,27 @@+import { useClickOutsideElement } from "#/hooks/use-click-outside-element";+import { ContextMenu } from "../context-menu/context-menu";+import { ContextMenuListItem } from "../context-menu/context-menu-list-item";++interface ConversationCardContextMenuProps {+ onClose: () => void;+ onDelete: (event: React.MouseEvent<HTMLButtonElement>) => void;+}++export function ConversationCardContextMenu({+ onClose,+ onDelete,+}: ConversationCardContextMenuProps) {+ const ref = useClickOutsideElement<HTMLUListElement>(onClose);++ return (+ <ContextMenu+ ref={ref}+ testId="context-menu"+ className="left-full float-right"+ >+ <ContextMenuListItem testId="delete-button" onClick={onDelete}>+ Delete+ </ContextMenuListItem>+ </ContextMenu>+ );+}diff --git a/frontend/src/components/features/conversation-panel/conversation-card.tsx b/frontend/src/components/features/conversation-panel/conversation-card.tsxindex c10e90f005..5f44f5b527 100644--- a/frontend/src/components/features/conversation-panel/conversation-card.tsx+++ b/frontend/src/components/features/conversation-panel/conversation-card.tsx@@ -5,11 +5,10 @@ import {ProjectStatus,ConversationStateIndicator,} from "./conversation-state-indicator";-import { ContextMenu } from "../context-menu/context-menu";-import { ContextMenuListItem } from "../context-menu/context-menu-list-item";import { EllipsisButton } from "./ellipsis-button";+import { ConversationCardContextMenu } from "./conversation-card-context-menu";-interface ProjectCardProps {+interface ConversationCardProps {onClick: () => void;onDelete: () => void;onChangeTitle: (title: string) => void;@@ -27,7 +26,7 @@ export function ConversationCard({selectedRepository,lastUpdatedAt,status = "STOPPED",-}: ProjectCardProps) {+}: ConversationCardProps) {const [contextMenuVisible, setContextMenuVisible] = React.useState(false);const inputRef = React.useRef<HTMLInputElement>(null);@@ -86,11 +85,10 @@ export function ConversationCard({</div></div>{contextMenuVisible && (- <ContextMenu testId="context-menu" className="left-full float-right">- <ContextMenuListItem testId="delete-button" onClick={handleDelete}>- Delete- </ContextMenuListItem>- </ContextMenu>+ <ConversationCardContextMenu+ onClose={() => setContextMenuVisible(false)}+ onDelete={handleDelete}+ />)}{selectedRepository && (<ConversationRepoLink