From d052d221dc3c102979f9df017d7cc78e193c0998 Mon Sep 17 00:00:00 2001 From: Daniel Avila Date: Wed, 15 Mar 2023 18:05:34 -0400 Subject: [PATCH] chore: switch focus to textarea when custom model change (still need to figure out reg model change) --- client/src/components/Main/TextChat.jsx | 4 ++-- client/src/components/Messages/TextWrapper.jsx | 2 +- client/src/components/Models/ModelMenu.jsx | 11 ++++------- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/client/src/components/Main/TextChat.jsx b/client/src/components/Main/TextChat.jsx index e0363cd8b1..0de24e7f52 100644 --- a/client/src/components/Main/TextChat.jsx +++ b/client/src/components/Main/TextChat.jsx @@ -28,7 +28,7 @@ export default function TextChat({ messages }) { // auto focus to input, when enter a conversation. useEffect(() => { inputRef.current?.focus(); - }, [convo?.conversationId, ]) + }, [convo?.conversationId,]) const messageHandler = (data, currentState, currentMsg) => { const { messages, _currentMsg, message, sender } = currentState; @@ -185,11 +185,11 @@ export default function TextChat({ messages }) { sender, }; console.log('User Input:', message); - // handleSubmit(submission); dispatch(setSubmission(submission)); }; useEffect(() => { + inputRef.current?.focus(); if (Object.keys(submission).length === 0) { return; } diff --git a/client/src/components/Messages/TextWrapper.jsx b/client/src/components/Messages/TextWrapper.jsx index 75766bca0c..3cfd0a1b37 100644 --- a/client/src/components/Messages/TextWrapper.jsx +++ b/client/src/components/Messages/TextWrapper.jsx @@ -154,7 +154,7 @@ export default function TextWrapper({ text, generateCursor }) { return ( <> {result} - {(<>{generateCursor()})} + {generateCursor()} ); } diff --git a/client/src/components/Models/ModelMenu.jsx b/client/src/components/Models/ModelMenu.jsx index 4e47ccbb1b..3e3333a7cc 100644 --- a/client/src/components/Models/ModelMenu.jsx +++ b/client/src/components/Models/ModelMenu.jsx @@ -65,14 +65,13 @@ export default function ModelMenu() { localStorage.setItem('model', JSON.stringify(model)); }, [model]); - const onChange = (value, custom = false) => { + const onChange = (value) => { if (!value) { return; } else if (value === model) { return; } else if (value === 'chatgptCustom') { - // dispatch(setMessages([])); - return; + // return; } else if (initial[value]) { dispatch(setModel(value)); dispatch(setDisabled(false)); @@ -84,9 +83,7 @@ export default function ModelMenu() { dispatch(setCustomGpt({ chatGptLabel, promptPrefix })); dispatch(setModel('chatgptCustom')); dispatch(setCustomModel(value)); - // if (custom) { - // setMenuOpen((prevOpen) => !prevOpen); - // } + setMenuOpen(false); } else if (!modelMap[value]) { dispatch(setCustomModel(null)); } @@ -160,7 +157,7 @@ export default function ModelMenu() { {icon} - + event.preventDefault()}> Select a Model