From d1f42d47fe577576229b3d2125c65a9bd68e4596 Mon Sep 17 00:00:00 2001 From: lyzno1 Date: Sat, 11 Oct 2025 12:22:56 +0800 Subject: [PATCH] fix: improve dropdown menu hover and positioning --- .../components/workflow/comment/thread.tsx | 31 ++++++++++++++----- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/web/app/components/workflow/comment/thread.tsx b/web/app/components/workflow/comment/thread.tsx index 770be0b6812..34a52de771b 100644 --- a/web/app/components/workflow/comment/thread.tsx +++ b/web/app/components/workflow/comment/thread.tsx @@ -197,6 +197,21 @@ export const CommentThread: FC = memo(({ const previousReplyCountRef = useRef(replies.length) const previousCommentIdRef = useRef(comment.id) + // Close dropdown when clicking outside + useEffect(() => { + if (!activeReplyMenuId) + return + + const handleClickOutside = (e: MouseEvent) => { + const target = e.target as HTMLElement + if (!target.closest('[data-reply-menu]')) + setActiveReplyMenuId(null) + } + + document.addEventListener('click', handleClickOutside) + return () => document.removeEventListener('click', handleClickOutside) + }, [activeReplyMenuId]) + useEffect(() => { const container = messageListRef.current if (!container) @@ -309,17 +324,22 @@ export const CommentThread: FC = memo(({ /> {replies.length > 0 && (
- {replies.map((reply, index) => { + {replies.map((reply) => { const isReplyEditing = editingReply?.id === reply.id const isOwnReply = reply.created_by_account?.id === userProfile?.id - const isLastReply = index === replies.length - 1 return (
{isOwnReply && !isReplyEditing && ( -
+
{activeReplyMenuId === reply.id && ( -
+