Skip to content

Commit

Permalink
Merge pull request #153 from Pleasurecruise/main
Browse files Browse the repository at this point in the history
fix: update commentsubmit.tsx
  • Loading branch information
521xueweihan authored Dec 10, 2024
2 parents e841711 + f88dc9a commit 63d2028
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/components/respository/CommentSubmit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,14 @@ function CommentSubmit(props: CommentSubmitProps) {

const handleInput: FormEventHandler<HTMLTextAreaElement> = (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`;
}

e.currentTarget.style.height = 'auto';
const newHeight = Math.max(e.currentTarget.scrollHeight + 2, 58);
e.currentTarget.style.height = `${newHeight}px`;

setCommentData({
...commentData,
comment: value,
comment: value.trim(),
height: e.currentTarget.scrollHeight + 2,
});
};
Expand Down

0 comments on commit 63d2028

Please sign in to comment.