Skip to content

Commit

Permalink
Merge pull request #152 from Pleasurecruise/main
Browse files Browse the repository at this point in the history
fix: textarea height problem
  • Loading branch information
521xueweihan authored Dec 8, 2024
2 parents 66423ad + 2231a72 commit ba005ba
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 @@ -30,14 +30,11 @@ function CommentSubmit(props: CommentSubmitProps) {
const { t, belongId, className, onSuccess, onFail } = props;

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`;
}
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,
Expand Down

0 comments on commit ba005ba

Please sign in to comment.