From 8bd5a9cb3bb658c8559971617a379af5b4420f28 Mon Sep 17 00:00:00 2001 From: Nikita Date: Wed, 28 Aug 2024 12:06:21 +0300 Subject: [PATCH] fix(comments): add cancel button and format toolbar when editing message --- .../src/components/comment_feed/comment.tsx | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/front_end/src/components/comment_feed/comment.tsx b/front_end/src/components/comment_feed/comment.tsx index 3928aaa69a..6a5350a7dc 100644 --- a/front_end/src/components/comment_feed/comment.tsx +++ b/front_end/src/components/comment_feed/comment.tsx @@ -144,6 +144,7 @@ const Comment: FC = ({ const [isDeleted, setIsDeleted] = useState(comment.is_soft_deleted); const [isReplying, setIsReplying] = useState(false); const [commentMarkdown, setCommentMarkdown] = useState(comment.text); + const [tempCommentMarkdown, setTempCommentMarkdown] = useState(""); const [isReportModalOpen, setIsReportModalOpen] = useState(false); const { user } = useAuth(); @@ -218,6 +219,7 @@ const Comment: FC = ({ id: "edit", name: t("edit"), onClick: () => { + setTempCommentMarkdown(commentMarkdown); setIsEditing(true); }, }, @@ -346,15 +348,19 @@ const Comment: FC = ({ )} */}
- { - setCommentMarkdown(text); - }} - /> + {isEditing && ( + + )}{" "} + {!isEditing && ( + + )}
{isEditing && ( + <> + + }} + > + {t("cancel")} + + )}