diff --git a/frontend/src/pages/app/ui/components/chat/ChatInputWrapper.tsx b/frontend/src/pages/app/ui/components/chat/ChatInputWrapper.tsx index 1f12f82..89df0f9 100644 --- a/frontend/src/pages/app/ui/components/chat/ChatInputWrapper.tsx +++ b/frontend/src/pages/app/ui/components/chat/ChatInputWrapper.tsx @@ -66,18 +66,24 @@ export function ChatInputWrapper( setAttachmentsVisible(selectedFiles.length > 0); }, [selectedFiles]); - function handleEmojiButtonClick() { - if (chatInputWrapperRef.current && messagePanelRef?.current) { - const inputRect = chatInputWrapperRef.current.getBoundingClientRect(); - const panelRect = messagePanelRef.current.getBoundingClientRect(); - - // Position menu 10px from message panel edge and 10px above the chat input - // The animation will start 30px below this position - setEmojiMenuPosition({ - x: panelRect.left + 10, // 10px from message panel edge - y: window.innerHeight - inputRect.top + 10 // 10px above the top of chat input - }); - setEmojiMenuOpen(true); + function handleEmojiButtonClick(e: React.MouseEvent) { + e.stopPropagation(); + + if (!emojiMenuOpen) { + if (chatInputWrapperRef.current && messagePanelRef?.current) { + const inputRect = chatInputWrapperRef.current.getBoundingClientRect(); + const panelRect = messagePanelRef.current.getBoundingClientRect(); + + // Position menu 10px from message panel edge and 10px above the chat input + // The animation will start 30px below this position + setEmojiMenuPosition({ + x: panelRect.left + 10, // 10px from message panel edge + y: window.innerHeight - inputRect.top + 10 // 10px above the top of chat input + }); + setEmojiMenuOpen(true); + } + } else { + setEmojiMenuOpen(false); } }; @@ -176,7 +182,12 @@ export function ChatInputWrapper(
- + e.stopPropagation()} + onMouseUp={e => e.stopPropagation()} + className="emoji-btn" />