diff --git a/src/components/respository/CommentSubmit.tsx b/src/components/respository/CommentSubmit.tsx index 53e3d11..b02b9bf 100644 --- a/src/components/respository/CommentSubmit.tsx +++ b/src/components/respository/CommentSubmit.tsx @@ -30,14 +30,11 @@ function CommentSubmit(props: CommentSubmitProps) { const { t, belongId, className, onSuccess, onFail } = props; const handleInput: FormEventHandler = (e) => { - const { value } = e.currentTarget; - if (value.length == 0) { - e.currentTarget.style.height = `58px`; - } else { - // 自动增加输入框的高度 - // 2 是 上下两个 border 的高度 - e.currentTarget.style.height = `${e.currentTarget.scrollHeight + 2}px`; - } + const value = e.currentTarget.value.trim(); + + e.currentTarget.style.height = 'auto'; + const newHeight = Math.max(e.currentTarget.scrollHeight + 2, 58); + e.currentTarget.style.height = `${newHeight}px`; setCommentData({ ...commentData,