diff --git a/packages/touchpoint-ui/src/App.tsx b/packages/touchpoint-ui/src/App.tsx index a05c456..2494bca 100644 --- a/packages/touchpoint-ui/src/App.tsx +++ b/packages/touchpoint-ui/src/App.tsx @@ -217,6 +217,7 @@ const App = forwardRef((props, ref) => { <> = ({ const [uploadErrorMessage, setUploadErrorMessage] = useState( null, ); - const [fileInfo, setFileInfo] = useState(null); + const [uploadedFileInfo, setUploadedFileInfo] = useState( + null, + ); const fileInputRef = useRef(null); const textInputRef = useRef(null); + const isMd = useTailwindMediaQuery("md"); + + // Autofocus input on desktop only useEffect(() => { - textInputRef.current?.focus(); - }, []); + if (isMd) { + textInputRef.current?.focus(); + } + }, [isMd]); const isInputEmpty = useMemo(() => { return inputValue.trim() === ""; @@ -64,7 +72,7 @@ const ChatInput: FC = ({ if (isInputEmpty) { return; } - if (uploadUrl != null && fileInfo != null) { + if (uploadUrl != null && uploadedFileInfo != null) { handler.sendStructured({ uploadIds: [uploadUrl.uploadId], utterance: inputValue, @@ -73,7 +81,7 @@ const ChatInput: FC = ({ handler.sendText(inputValue); } setInputValue(""); - setFileInfo(null); + setUploadedFileInfo(null); }; const isUploadEnabled = uploadUrl != null; @@ -94,7 +102,7 @@ const ChatInput: FC = ({ } const { name, size, type } = file; - setFileInfo({ name, size, type }); + setUploadedFileInfo({ name, size, type }); if (size / 1024 ** 2 > MAX_INPUT_FILE_SIZE_IN_MB) { setUploadErrorMessage( @@ -138,7 +146,7 @@ const ChatInput: FC = ({
{uploadErrorMessage != null && ( @@ -147,16 +155,16 @@ const ChatInput: FC = ({ {uploadErrorMessage}
)} - {fileInfo && ( + {uploadedFileInfo && ( <>

{uploadErrorMessage != null ? ( ) : ( - + )} - {fileInfo.name} + {uploadedFileInfo.name}

= ({ onClick={ isUploadEnabled ? () => { - setFileInfo(null); + setUploadedFileInfo(null); setUploadErrorMessage(null); if (fileInputRef.current != null) { fileInputRef.current.value = ""; @@ -180,7 +188,7 @@ const ChatInput: FC = ({ )}
- {isUploadEnabled ? ( + {isUploadEnabled && uploadedFileInfo == null ? ( <>