diff --git a/web/app/components/workflow/comment/thread.tsx b/web/app/components/workflow/comment/thread.tsx index 770be0b681..34a52de771 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 && ( -
+