Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update commentsubmit.tsx #153

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading