Skip to content

Commit bd573d6

Browse files
committed
refactor: default max length for comment form
1 parent af646b4 commit bd573d6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/components/viewer/comment/CommentForm.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { sendComment } from 'apis/comment'
44
import clsx from 'clsx'
55
import { useContext, useState } from 'react'
66

7+
import { MAX_COMMENT_LENGTH } from '../../../models/comment'
78
import { formatError } from '../../../utils/error'
89
import { wrapErrorMessage } from '../../../utils/wrapErrorMessage'
910
import { Markdown } from '../../Markdown'
@@ -23,7 +24,7 @@ export const CommentForm = ({
2324
primary,
2425
placeholder = '发一条友善的评论吧',
2526
inputAutoFocus,
26-
maxLength,
27+
maxLength = MAX_COMMENT_LENGTH,
2728
}: CommentFormProps) => {
2829
const { operationId, replyTo, reload } = useContext(CommentAreaContext)
2930

@@ -83,7 +84,7 @@ export const CommentForm = ({
8384
rows={2}
8485
growVertically
8586
large
86-
maxLength={maxLength ?? 150}
87+
maxLength={maxLength}
8788
placeholder={placeholder}
8889
value={message}
8990
onChange={(e) => setMessage(e.target.value)}
@@ -112,7 +113,7 @@ export const CommentForm = ({
112113
</Checkbox>
113114

114115
<div className="ml-auto text-slate-500 text-sm">
115-
{message.length}/{maxLength ?? 150}
116+
{message.length}/{maxLength}
116117
</div>
117118
</div>
118119

0 commit comments

Comments
 (0)