diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatInput/components/textAreaWrapper/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatInput/components/textAreaWrapper/index.tsx index 25e2a33f0..29f88453a 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatInput/components/textAreaWrapper/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatInput/components/textAreaWrapper/index.tsx @@ -2,10 +2,6 @@ import { Textarea } from "../../../../../../../components/ui/textarea"; import { classNames } from "../../../../../../../utils/utils"; const TextAreaWrapper = ({ - dragOver, - dragEnter, - dragLeave, - onDrop, checkSendingOk, send, lockChat, @@ -54,10 +50,6 @@ const TextAreaWrapper = ({ e.target.style.borderTopWidth = "0"; }} onBlur={() => setInputFocus(false)} - onDragOver={dragOver} - onDragEnter={dragEnter} - onDragLeave={dragLeave} - onDrop={onDrop} onKeyDown={(event) => { if (checkSendingOk(event)) { send(); diff --git a/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx index 4dbaf6e93..6ca07dcc7 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/chatInput/index.tsx @@ -26,12 +26,13 @@ export default function ChatInput({ setChatValue, inputRef, noInput, + files, + setFiles, + isDragging, }: chatInputType): JSX.Element { const [repeat, setRepeat] = useState(1); const saveLoading = useFlowsManagerStore((state) => state.saveLoading); const currentFlowId = useFlowsManagerStore((state) => state.currentFlowId); - const [files, setFiles] = useState([]); - const [isDragging, setIsDragging] = useState(false); const [inputFocus, setInputFocus] = useState(false); const fileInputRef = useRef(null); @@ -40,12 +41,6 @@ export default function ChatInput({ useUpload(uploadFile, currentFlowId, setFiles); const { handleFileChange } = useHandleFileChange(setFiles, currentFlowId); - const { dragOver, dragEnter, dragLeave, onDrop } = useDragAndDrop( - setIsDragging, - setFiles, - currentFlowId, - ); - const send = () => { sendMessage({ repeat, @@ -74,10 +69,6 @@ export default function ChatInput({
{ - setFiles((prev) => prev.filter((f) => f.id !== file.id)); + setFiles((prev: FilePreviewType[]) => + prev.filter((f) => f.id !== file.id), + ); // TODO: delete file on backend }} /> diff --git a/src/frontend/src/modals/IOModal/components/chatView/index.tsx b/src/frontend/src/modals/IOModal/components/chatView/index.tsx index a2bcc04e4..208a8c704 100644 --- a/src/frontend/src/modals/IOModal/components/chatView/index.tsx +++ b/src/frontend/src/modals/IOModal/components/chatView/index.tsx @@ -10,10 +10,11 @@ import useFlowStore from "../../../../stores/flowStore"; import useFlowsManagerStore from "../../../../stores/flowsManagerStore"; import { VertexBuildTypeAPI, sendAllProps } from "../../../../types/api"; import { ChatMessageType, ChatOutputType } from "../../../../types/chat"; -import { chatViewProps } from "../../../../types/components"; +import { chatViewProps, FilePreviewType } from "../../../../types/components"; import { classNames } from "../../../../utils/utils"; import ChatInput from "./chatInput"; import ChatMessage from "./chatMessage"; +import useDragAndDrop from "./chatInput/hooks/use-drag-and-drop"; export default function ChatView({ sendMessage, @@ -141,9 +142,23 @@ export default function ChatView({ // return newChatHistory; // }); } + const [files, setFiles] = useState([]); + const [isDragging, setIsDragging] = useState(false); + + const { dragOver, dragEnter, dragLeave, onDrop } = useDragAndDrop( + setIsDragging, + setFiles, + currentFlowId, + ); return ( -
+
diff --git a/src/frontend/src/types/components/index.ts b/src/frontend/src/types/components/index.ts index c09feb13b..e3ce35840 100644 --- a/src/frontend/src/types/components/index.ts +++ b/src/frontend/src/types/components/index.ts @@ -485,6 +485,11 @@ export type headerFlowsType = { }; export type chatInputType = { + isDragging: boolean; + files: FilePreviewType[]; + setFiles: ( + files: FilePreviewType[] | ((prev: FilePreviewType[]) => FilePreviewType[]), + ) => void; chatValue: string; inputRef: { current: any;