diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-02-14 15:48:34 +0100 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-02-14 15:54:54 +0100 |
| commit | 1b34f85f0e3188861c6804666f02b4495cab033c (patch) | |
| tree | 0f26c9b73b8cc47c7136bad6167a0f18a08fd835 /src/components/Comment/Comment.tsx | |
| parent | 637350e4d152de1346857d645bda8443900ec6f4 (diff) | |
chore: improve comment form user experience
Diffstat (limited to 'src/components/Comment/Comment.tsx')
| -rw-r--r-- | src/components/Comment/Comment.tsx | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/components/Comment/Comment.tsx b/src/components/Comment/Comment.tsx index ab1dffc..a263771 100644 --- a/src/components/Comment/Comment.tsx +++ b/src/components/Comment/Comment.tsx @@ -24,7 +24,7 @@ const Comment = ({ const intl = useIntl(); const router = useRouter(); const locale = router.locale ? router.locale : settings.locales.defaultLocale; - const [isReply, setIsReply] = useState<boolean>(false); + const [shouldOpenForm, setShouldOpenForm] = useState<boolean>(false); const firstFieldRef = useRef<HTMLInputElement>(null); useEffect(() => { @@ -98,21 +98,25 @@ const Comment = ({ ></div> {!isNested && ( <footer className={styles.footer}> - <Button clickHandler={() => setIsReply((prev) => !prev)}> - {intl.formatMessage({ - defaultMessage: 'Reply', - description: 'Comment: reply button', - })} + <Button clickHandler={() => setShouldOpenForm((prev) => !prev)}> + {shouldOpenForm + ? intl.formatMessage({ + defaultMessage: 'Cancel reply', + description: 'Comment: reply button', + }) + : intl.formatMessage({ + defaultMessage: 'Reply', + description: 'Comment: reply button', + })} </Button> </footer> )} </article> - {isReply && ( + {shouldOpenForm && ( <CommentForm ref={firstFieldRef} articleId={articleId} parentId={comment.commentId} - isReply={isReply} /> )} {comment.replies.length > 0 && ( |
