Skip to content

Commit

Permalink
refactor: default max length for comment form
Browse files Browse the repository at this point in the history
  • Loading branch information
guansss committed Sep 5, 2024
1 parent af646b4 commit bd573d6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/viewer/comment/CommentForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { sendComment } from 'apis/comment'
import clsx from 'clsx'
import { useContext, useState } from 'react'

import { MAX_COMMENT_LENGTH } from '../../../models/comment'
import { formatError } from '../../../utils/error'
import { wrapErrorMessage } from '../../../utils/wrapErrorMessage'
import { Markdown } from '../../Markdown'
Expand All @@ -23,7 +24,7 @@ export const CommentForm = ({
primary,
placeholder = '发一条友善的评论吧',
inputAutoFocus,
maxLength,
maxLength = MAX_COMMENT_LENGTH,
}: CommentFormProps) => {
const { operationId, replyTo, reload } = useContext(CommentAreaContext)

Expand Down Expand Up @@ -83,7 +84,7 @@ export const CommentForm = ({
rows={2}
growVertically
large
maxLength={maxLength ?? 150}
maxLength={maxLength}
placeholder={placeholder}
value={message}
onChange={(e) => setMessage(e.target.value)}
Expand Down Expand Up @@ -112,7 +113,7 @@ export const CommentForm = ({
</Checkbox>

<div className="ml-auto text-slate-500 text-sm">
{message.length}/{maxLength ?? 150}
{message.length}/{maxLength}
</div>
</div>

Expand Down

0 comments on commit bd573d6

Please sign in to comment.