File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
src/components/respository Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -31,17 +31,14 @@ function CommentSubmit(props: CommentSubmitProps) {
31
31
32
32
const handleInput : FormEventHandler < HTMLTextAreaElement > = ( e ) => {
33
33
const { value } = e . currentTarget ;
34
- if ( value . length == 0 ) {
35
- e . currentTarget . style . height = `58px` ;
36
- } else {
37
- // 自动增加输入框的高度
38
- // 2 是 上下两个 border 的高度
39
- e . currentTarget . style . height = `${ e . currentTarget . scrollHeight + 2 } px` ;
40
- }
34
+
35
+ e . currentTarget . style . height = 'auto' ;
36
+ const newHeight = Math . max ( e . currentTarget . scrollHeight + 2 , 58 ) ;
37
+ e . currentTarget . style . height = `${ newHeight } px` ;
41
38
42
39
setCommentData ( {
43
40
...commentData ,
44
- comment : value ,
41
+ comment : value . trim ( ) ,
45
42
height : e . currentTarget . scrollHeight + 2 ,
46
43
} ) ;
47
44
} ;
You can’t perform that action at this time.
0 commit comments