diff --git a/src/pages/common/components/ChatComponent/ChatComponent.tsx b/src/pages/common/components/ChatComponent/ChatComponent.tsx index 4260022069..a1e4835d05 100644 --- a/src/pages/common/components/ChatComponent/ChatComponent.tsx +++ b/src/pages/common/components/ChatComponent/ChatComponent.tsx @@ -576,6 +576,20 @@ export default function ChatComponent({ } }, [discussionMessages.length]); + useEffect(() => { + const handlePaste = (event) => { + if (event.clipboardData.files.length) { + uploadFiles(event); + } + }; + + chatInputWrapperRef.current?.addEventListener("paste", handlePaste); + + return () => { + chatInputWrapperRef.current?.removeEventListener("paste", handlePaste); + }; + }, []); + const renderChatInput = (): ReactNode => { const shouldHideChatInput = !isChatChannel && (!hasAccess || isHidden); @@ -593,20 +607,6 @@ export default function ChatComponent({ return null; } - useEffect(() => { - const handlePaste = (event) => { - if (event.clipboardData.files.length) { - uploadFiles(event); - } - }; - - chatInputWrapperRef.current?.addEventListener("paste", handlePaste); - - return () => { - chatInputWrapperRef.current?.removeEventListener("paste", handlePaste); - }; - }, []); - return ( <>