diff --git a/src/components/ConversationCard/index.jsx b/src/components/ConversationCard/index.jsx index 1f14dba..11b5d6e 100644 --- a/src/components/ConversationCard/index.jsx +++ b/src/components/ConversationCard/index.jsx @@ -365,6 +365,8 @@ function ConversationCard(props) { { const newQuestion = new ConversationItemData('question', question + '\n
') const newAnswer = new ConversationItemData( @@ -382,7 +384,6 @@ function ConversationCard(props) { updateAnswer(e, false, 'error') } }} - port={port} /> ) diff --git a/src/components/InputBox/index.jsx b/src/components/InputBox/index.jsx index 34f983f..b7db950 100644 --- a/src/components/InputBox/index.jsx +++ b/src/components/InputBox/index.jsx @@ -3,13 +3,37 @@ import PropTypes from 'prop-types' import { updateRefHeight } from '../../utils' import { useTranslation } from 'react-i18next' -export function InputBox({ onSubmit, enabled, port }) { +export function InputBox({ onSubmit, enabled, port, reverseResizeDir }) { const { t } = useTranslation() const [value, setValue] = useState('') + const reverseDivRef = useRef(null) const inputRef = useRef(null) + const resizedRef = useRef(false) + + const virtualInputRef = reverseResizeDir ? reverseDivRef : inputRef useEffect(() => { - updateRefHeight(inputRef) + const onResizeY = () => { + if (virtualInputRef.current.h !== virtualInputRef.current.offsetHeight) { + virtualInputRef.current.h = virtualInputRef.current.offsetHeight + if (!resizedRef.current) { + resizedRef.current = true + virtualInputRef.current.style.maxHeight = '' + } + } + } + virtualInputRef.current.h = virtualInputRef.current.offsetHeight + virtualInputRef.current.addEventListener('mousemove', onResizeY) + }, []) + + useEffect(() => { + if (!resizedRef.current) { + if (!reverseResizeDir) { + updateRefHeight(inputRef) + virtualInputRef.current.h = virtualInputRef.current.offsetHeight + virtualInputRef.current.style.maxHeight = '160px' + } + } }) useEffect(() => { @@ -33,20 +57,37 @@ export function InputBox({ onSubmit, enabled, port }) { return (
-