diff --git a/web/app/components/workflow/comment-manager.tsx b/web/app/components/workflow/comment-manager.tsx index 58fa93fa3d..81a4d45842 100644 --- a/web/app/components/workflow/comment-manager.tsx +++ b/web/app/components/workflow/comment-manager.tsx @@ -10,8 +10,14 @@ const CommentManager = () => { const { controlMode, mousePosition } = workflowStore.getState() if (controlMode === 'comment') { - e.preventDefault() - handleCreateComment(mousePosition) + const target = e.target as HTMLElement + const isInDropdown = target.closest('[data-mention-dropdown]') + const isInCommentInput = target.closest('[data-comment-input]') + + if (!isInDropdown && !isInCommentInput) { + e.preventDefault() + handleCreateComment(mousePosition) + } } }) diff --git a/web/app/components/workflow/comment/input.tsx b/web/app/components/workflow/comment/input.tsx index d122d690f6..ac20064839 100644 --- a/web/app/components/workflow/comment/input.tsx +++ b/web/app/components/workflow/comment/input.tsx @@ -107,6 +107,31 @@ export const CommentInput: FC = memo(({ position, onSubmit, o }, 0) }, []) + const handleMentionButtonClick = useCallback((e: React.MouseEvent) => { + e.preventDefault() + e.stopPropagation() + console.log('Mention button clicked!') + + const textarea = textareaRef.current + if (!textarea) return + + const cursorPosition = textarea.selectionStart || 0 + const newContent = `${content.slice(0, cursorPosition)}@${content.slice(cursorPosition)}` + + setContent(newContent) + + setTimeout(() => { + const newCursorPos = cursorPosition + 1 + textarea.setSelectionRange(newCursorPos, newCursorPos) + textarea.focus() + + setMentionQuery('') + setMentionPosition(cursorPosition) + setShowMentionDropdown(true) + setSelectedMentionIndex(0) + }, 0) + }, [content]) + const insertMention = useCallback((user: UserProfile) => { const textarea = textareaRef.current if (!textarea) return @@ -126,7 +151,13 @@ export const CommentInput: FC = memo(({ position, onSubmit, o }, 0) }, [content, mentionPosition]) - const handleSubmit = useCallback(() => { + const handleSubmit = useCallback((e?: React.MouseEvent) => { + if (e) { + e.preventDefault() + e.stopPropagation() + } + console.log('Submit button clicked!') + try { if (content.trim()) { onSubmit(content.trim(), mentionedUserIds) @@ -180,6 +211,7 @@ export const CommentInput: FC = memo(({ position, onSubmit, o left: screenPosition.x, top: screenPosition.y, }} + data-comment-input >
@@ -209,7 +241,7 @@ export const CommentInput: FC = memo(({ position, onSubmit, o